简体   繁体   English

我已经安装了 Fuzzywuzzy 模块,但是当我在 jupyter notebook 中导入它时,它给出了错误 no module found

[英]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创建和激活虚拟环境的说明:

Mac OS & Linux: How To Setup Virtual Environment Mac OS 和 Linux:如何设置虚拟环境

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离开虚拟环境。

Windows: How To Setup Virtual Environment Windows:如何设置虚拟环境

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.

相关问题 无法在 jupyter notebook 上导入fuzzywuzzy模块 - can not import fuzzywuzzy module on jupyter notebook 我已经在pip中安装了pandas_datareader,但是当我尝试在Jupyter Notebook中导入pandas_datareader时,提示模块未找到 - I have installed pandas_datareader in pip but when I try to import the same in Jupyter Notebook it says Module not found 当我尝试导入模块时在Jupyter Notebook NameError中 - In Jupyter Notebook NameError when I try to import a module "当我尝试使用 Python 3.8 在 jupyter notebook 中安装 PySimpleGUI (4.53.0) 时,错误“没有返回名为‘PySimpleGUI’的模块" - When I try to install PySimpleGUI (4.53.0) in jupyter notebook using Python 3.8 the error "no module named 'PySimpleGUI' is returned 在 Jupyter Notebook 中导入期间找不到模块 - Module Not found during import in Jupyter Notebook jupyter 笔记本导入错误:没有名为“matplotlib”的模块 - jupyter notebook import error: no module named 'matplotlib' 我已经在Windows中安装了TensorFlow,但是当我尝试将其导入Jupyter Notebook时出现错误 - I have installed TensorFlow in my Windows but I get an Error when I try to import it in my Jupyter Notebook 无法在 jupyter notebook 中安装模块 - Cannot install a module in jupyter notebook Jupyter 笔记本找不到 Tensorflow 模块 - Tensorflow module not found by Jupyter notebook Python:在 Jupyter Notebook 中找不到模块 - Python: Module Not Found in Jupyter Notebook
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM