我已经安装了fuzzywuzzy模块,并且我可以在python shell中导入,当我将其导入到jupyter笔记本中时,它会显示错误:找不到模块。
>>> from fuzzywuzzy import fuzz
>>>'''
```import pandas as pd导入json
从fuzzywuzzy导入fuzz`
Traceback (most recent call last)
<ipython-input-2-a67086b59a14> in <module>
1 import pandas as pd
2 import json
---> 3 from fuzzywuzzy import fuzz
ModuleNotFoundError: No module named 'fuzzywuzzy'```发布于 2019-07-17 13:37:17
这种错误经常发生。我建议使用虚拟环境,然后使用pip install fuzzywuzzy,这是最理想和可靠的fire解决方案。以下是使用venv创建和激活虚拟环境的说明:
Mac OS & Linux:如何设置虚拟环境
1)克隆存储库后,使用cd进入存储库并运行以下命令:python3 -m venv venv
This will create the virtual environment. Make sure to name it venv because the .gitignore file
has been initialized to ignore it by default. 2)通过运行以下命令激活虚拟环境:source venv/bin/activate
3)随时可以运行deactivate离开虚拟环境。
Windows:如何设置虚拟环境
1)克隆存储库后,使用cd进入存储库并运行以下命令:python -m venv venv
This will create the virtual environment. Make sure to name it venv because the .gitignore file
has been initialized to ignore it by default. 2)通过运行以下命令激活虚拟环境:venv\Scripts\activate.bat
To activate the virtual environment inside of a code editor's bash, run: venv\Scripts\activate.ps13)随时可以运行deactivate离开虚拟环境。
发布于 2020-06-17 08:10:12
比较shell和notebook中的sys.executable和sys.path。您是否使用相同的站点包位置运行相同的解释器?- Amadan Jul 17 '19 at 5:32
这就是我的答案!我复制了shell中的sys.path结果,以便在笔记本中分配sys.path,如下所示:
sys.path = ['list-of-paths-from-my-shell']
然后,它解决了!
对啰。
https://stackoverflow.com/questions/57069047
复制相似问题