[英]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:一些尝试:
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.