python - import nltk 在 Python 中不工作(nltk 和 numpy 已成功安装,pip 工作)
问题描述
我在这里遇到了这个问题的许多版本,但我仍然找不到答案或弄清楚为什么import nltk
不能在 Python 中工作。我有 Windows 10,我卸载并重新下载了 32 位和 64 位版本的 Python(目前我只安装了 64 位版本),这就是我的命令提示符的样子:
(base) C:\Users\Cathryn>py -3.8-32 -m pip install -U nltk
Collecting nltk
Downloading nltk-3.6.1-py3-none-any.whl (1.5 MB)
|████████████████████████████████| 1.5 MB 6.8 MB/s
Requirement already satisfied, skipping upgrade: joblib in c:\users\cathryn\anaconda3\lib\site-packages (from nltk) (0.17.0)
Requirement already satisfied, skipping upgrade: tqdm in c:\users\cathryn\anaconda3\lib\site-packages (from nltk) (4.50.2)
Requirement already satisfied, skipping upgrade: regex in c:\users\cathryn\anaconda3\lib\site-packages (from nltk) (2020.10.15)
Requirement already satisfied, skipping upgrade: click in c:\users\cathryn\anaconda3\lib\site-packages (from nltk) (7.1.2)
Installing collected packages: nltk
Attempting uninstall: nltk
Found existing installation: nltk 3.5
Uninstalling nltk-3.5:
Successfully uninstalled nltk-3.5
Successfully installed nltk-3.6.1
(base) C:\Users\Cathryn>pip install nltk
Requirement already satisfied: nltk in c:\users\cathryn\anaconda3\lib\site-packages (3.6.1)
Requirement already satisfied: joblib in c:\users\cathryn\anaconda3\lib\site-packages (from nltk) (0.17.0)
Requirement already satisfied: regex in c:\users\cathryn\anaconda3\lib\site-packages (from nltk) (2020.10.15)
Requirement already satisfied: tqdm in c:\users\cathryn\anaconda3\lib\site-packages (from nltk) (4.50.2)
Requirement already satisfied: click in c:\users\cathryn\anaconda3\lib\site-packages (from nltk) (7.1.2)
(base) C:\Users\Cathryn>pip install numpy
Requirement already satisfied: numpy in c:\users\cathryn\anaconda3\lib\site-packages (1.19.2)
然而,当我放入import nltk
Python IDLE 和看起来像 windows 命令提示符的 Python 窗口时,会发生这种情况:
>>> import nltk
Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
import nltk
ModuleNotFoundError: No module named 'nltk'
>>>
我遵循了https://www.nltk.org/install.html上的所有说明,而不是使用 64 位版本而不是推荐的 32 位版本。我像其他建议的答案一样下载了 Anaconda 。我真的不知道是什么导致了这个问题,我将不胜感激。
如果没有别的,感谢您阅读本文。
解决方案
您的编辑器可能使用了错误的解释器。它必须指向作为基础环境的“PathToAnaconda\python.exe”。
推荐阅读
- fragment-shader - 在 Godot 片段着色器中绘制矩形的问题
- python - 如何在python中编写两个相邻的函数?
- r - 计算 R tidyverse 环境中 2 个列表元素的所有组合的多个 t 检验
- javascript - PWA 应用可以发布到应用商店和游戏商店吗
- nlp - 在 nlplab Brat 注释工具中创建每个用户工作区
- java - MainActivity销毁后如何使用Service调用MainActivity方法
- influxdb - 存储在 InfluxDB 数据库中的值的移动平均值
- html - CSS - 样式化 nth-child 选择器
- rest - 如何使用 Spring MVC 构建一个简单的搜索页面?
- html - 在滚动的每个部分更改正文背景