简体   繁体   English

PyCharm 没有名为“nltk”的模块,即使我使用 pip3 安装了它?

[英]PyCharm No module named 'nltk' even though I've installed it using pip3?

import nltk
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
ModuleNotFoundError: No module named 'nltk'

This is the error that I get from running PyCharm 2021.3.2 (Community Edition).这是我运行 PyCharm 2021.3.2(社区版)时出现的错误。

However, when I go to my terminal and try pip3 install nltk但是,当我 go 到我的终端并尝试pip3 install nltk

I see that我看到

Requirement already satisfied: nltk in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (3.7)
Requirement already satisfied: click in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from nltk) (8.1.3)
Requirement already satisfied: regex>=2021.8.3 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from nltk) (2022.9.13)
Requirement already satisfied: joblib in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from nltk) (1.2.0)
Requirement already satisfied: tqdm in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from nltk) (4.64.1)

So it seems that I've already installed nltk ?所以看来我已经安装了nltk But why is PyCharm still giving me that error?但为什么 PyCharm 仍然给我那个错误? I'm using macOS Monterey 12.6 if that helps with anything.如果有任何帮助,我正在使用 macOS Monterey 12.6。

Some things to try:一些尝试:

  • On your terminal, check which on which python environment you're using your script.在您的终端上,检查您在哪个 python 环境中使用您的脚本。 It's a common source of headaches that using python 2.7 and python 3.x would not work for packages only installed with either pip or pip3.使用 python 2.7 和 python 3.x 不适用于仅使用 pip 或 pip3 安装的软件包,这是一个常见的令人头疼的问题。 On the terminal do在终端做
python --version

and (if available)和(如果有的话)

python3 --version

And check if you can make it work after installing the same package with pip (as opposed to pip3 ).并检查在安装相同的 package 和pip (与pip3相反)后是否可以正常工作。

  • using conda as a package manager can lead to millions of conflicts across your system.使用 conda 作为 package 管理器可能会导致整个系统发生数百万次冲突。 Are you by any chance using conda/anaconda?您是否有机会使用 conda/anaconda? If so, you should try intalling the package with conda instead of pip .如果是这样,您应该尝试使用 conda 安装conda而不是pip

  • check that whatever python you're using, it can reach the location of wherever you installled PyCharm.检查您使用的任何 python 是否可以到达您安装 PyCharm 的位置。

  • Check if your package was installed locally as opposed as globally.检查您的 package 是否安装在本地而不是全局。 For the former, do pip list on your terminal.对于前者,请在您的终端上执行pip list For the latter, do pip list --user instead.对于后者,改为执行pip list --user

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 库软件包不在模块PyCharm中,即使我已经安装了它 - Library package not in module PyCharm, even though I've already installed it ModuleNotFoundError:即使在 pip 在 Pycharm 中安装了请求后,也没有名为“请求”的模块 - ModuleNotFoundError: No module named 'requests' even after pip installed requests in Pycharm Python3 找不到 pip3 安装的模块,即使它安装了 defintley - Python3 cannot find module installed by pip3 even though it is deffintley installed “没有名为 x 的模块”,即使它刚刚与 pip 一起安装 - "No module named x" even though it was just installed with pip 即使我安装了它,也没有名为“Kivy”的模块 - No module named 'Kivy' even though I installed it “没有模块命名请求”,即使我安装了 pip,请求并将其添加到 PATH - “No Module Named Requests” even though I installed pip, requests, and added it to PATH ModuleNotFoundError:即使我安装了 pip 安装 websocket,也没有名为“websocket”的模块 - ModuleNotFoundError: No module named 'websocket' even though I installed pip install websocket 在 PyCharm 中使用 pip 成功安装后没有名为“pandas”的模块 - No module named 'pandas' after installed using pip successfully in PyCharm Pycharm 说没有 boto3 模块,即使我安装了 - Pycharm says no boto3 module even though I installed 即使我安装了 pycharm 也看不到模块“openpyxl” - pycharm cannot see the module "openpyxl" even though i installed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM