【发布时间】:2018-06-27 21:58:12
【问题描述】:
我正在使用 Atom 并且刚刚开始使用 Python。 当我尝试运行此代码时:
from textblob import TextBlob
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
analysis = TextBlob("TextBlob sure looks like it has some interesting
features")
print(analysis.tags)
我明白了:
Traceback (most recent call last):
File "/Users/bethwalsh/Documents/GitHub/automated-personas/py/test_001.py",
line 1, in <module>
from textblob import TextBlob
ImportError: No module named textblob
我尝试安装 textblob 但仍然没有变化:
$ pip3 install textblob
Requirement already satisfied: textblob in
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
(0.15.1)
有什么想法吗?
【问题讨论】:
-
您确定使用与安装
textblob相同的Python 解释器运行脚本吗?这看起来像 macOS,所以如果你只是用python myscript.py运行它,你使用的是 Apple 预装的 Python 2.7,而不是你的 Python 3.6。要使用后者,请使用python3 myscript.py。同样,如果您使用 Atom 运行脚本,您可能必须将其配置为使用/usr/local/bin/python3或/Library/Frameworks/Python.framework/Versions/3.6/bin/python3而不是/usr/bin/python。 -
还运行了“which python3”并将路径添加到我的文件“#!/Library/Frameworks/Python.framework/Versions/3.6/bin/python3”的顶部。现在一切正常,谢谢!
标签: python atom-editor textblob