我已按照在Windows 7 中安装 TextBlob for Python 的麻烦中的说明进行操作。它已安装,但是当我转到 Python Idle 并键入import TextBlob
时说
没有名为 TextBlob 的模块
如何解决这个问题呢?
或者我可以直接将包关联的库放在Python Lib文件夹中,并尝试在程序中导入?如果建议这样做,请告诉程序这样做。它会起作用吗?
任何帮助将不胜感激。
我已按照在Windows 7 中安装 TextBlob for Python 的麻烦中的说明进行操作。它已安装,但是当我转到 Python Idle 并键入import TextBlob
时说
没有名为 TextBlob 的模块
如何解决这个问题呢?
或者我可以直接将包关联的库放在Python Lib文件夹中,并尝试在程序中导入?如果建议这样做,请告诉程序这样做。它会起作用吗?
任何帮助将不胜感激。
用 conda 安装它。它对我有用!
conda install -c conda-forge textblob
在 Windows 中,如果您尝试在 python 中安装 textblob 或任何其他包,那么您必须授予用于安装包的应用程序的管理权限。
对我来说,当我通过 Pycharms 安装它时,它给出了同样的错误。我赋予了管理权限,它工作得很好!
pip install -U textblob
python -m textblob.download_corpora
from textblob import TextBlob
text = '''
The titular threat of The Blob has always struck me as the ultimate movie
monster: an insatiably hungry, amoeba-like mass able to penetrate
virtually any safeguard, capable of--as a doomed doctor chillingly
describes it--"assimilating flesh on contact.
Snide comparisons to gelatin be damned, it's a concept with the most
devastating of potential consequences, not unlike the grey goo scenario
proposed by technological theorists fearful of
artificial intelligence run rampant.
'''
blob = TextBlob(text)
blob.tags # [('The', 'DT'), ('titular', 'JJ'),
# ('threat', 'NN'), ('of', 'IN'), ...]
blob.noun_phrases # WordList(['titular threat', 'blob',
# 'ultimate movie monster',
# 'amoeba-like mass', ...])
for sentence in blob.sentences:
print(sentence.sentiment.polarity)
# 0.060
# -0.341
blob.translate(to="es") # 'La amenaza titular de The Blob...'
conda install -c conda-forge textblob
这在 Jupyter 环境中有效。