[英]I have install fuzzywuzzy module but when i import it in jupyter notebook it give error no module found
I have install fuzzywuzzy module and i can import in python shell when i import it in a jupyter notebook it gives error no module found.我已经安装了 Fuzzywuzzy 模块,当我在 jupyter notebook 中导入它时,我可以在 python shell 中导入它,它给出了没有找到模块的错误。
>>> from fuzzywuzzy import fuzz
>>>'''
```import pandas as pd
import json
from fuzzywuzzy import fuzz```
```ModuleNotFoundError
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'```
This error occurs a lot.这个错误经常发生。 I would recommend using a virtual environment and then doing
pip install fuzzywuzzy
This is the most optimal and sure fire solution.我建议使用虚拟环境,然后执行
pip install fuzzywuzzy
这是最优化和最可靠的解决方案。 The following are the instructions for creating and activating a virtual environment with venv:以下是使用venv创建和激活虚拟环境的说明:
1) After cloning the repo, cd
into the repo and run the command: python3 -m venv venv
1) 克隆 repo 后,
cd
进入 repo 并运行命令: 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) Activate the virtual environment by running the following command: source venv/bin/activate
2)通过运行以下命令激活虚拟环境:
source venv/bin/activate
3) At any moment, you can run deactivate
to leave the virtual environment. 3) 在任何时候,您都可以运行
deactivate
离开虚拟环境。
1) After cloning the repo, cd
into the repo and run the command: python -m venv venv
1)克隆repo后,
cd
进入repo并运行命令: 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) Activate the virtual environment by running the following command: venv\\Scripts\\activate.bat
2)通过运行以下命令激活虚拟环境:
venv\\Scripts\\activate.bat
To activate the virtual environment inside of a code editor's bash, run: venv\Scripts\activate.ps1
3) At any moment, you can run deactivate
to leave the virtual environment. 3) 在任何时候,您都可以运行
deactivate
离开虚拟环境。
Compare sys.executable and sys.path in shell vs notebook.
比较 shell 和 notebook 中的 sys.executable 和 sys.path。 Are you running the same interpreter, with same site packages location?
您是否运行相同的解释器,具有相同的站点包位置? – Amadan Jul 17 '19 at 5:32
– 阿马丹 19 年 7 月 17 日,5:32
This was the answer for me!这就是我的答案! I have copied the
sys.path
results from my shell to assign sys.path
within the notebook like this:我已经从我的 shell 复制了
sys.path
结果以在笔记本中分配sys.path
,如下所示:
sys.path = ['list-of-paths-from-my-shell']
Then, it solved!然后,就解决了!
Bingo.答对了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.