5

我已按照在Windows 7 中安装 TextBlob for Python 的麻烦中的说明进行操作。它已安装,但是当我转到 Python Idle 并键入import TextBlob时说

没有名为 TextBlob 的模块

如何解决这个问题呢?

或者我可以直接将包关联的库放在Python Lib文件夹中,并尝试在程序中导入?如果建议这样做,请告诉程序这样做。它会起作用吗?

任何帮助将不胜感激。

4

5 回答 5

4

用 conda 安装它。它对我有用!

conda install -c conda-forge textblob
于 2018-06-06T21:23:41.313 回答
3

尝试这个:

from textblob import TextBlob

来源:TextBlob 包说明

于 2014-07-04T13:11:04.793 回答
3

在 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...'
于 2017-02-27T06:01:16.547 回答
0

尝试

pip install textblob

如果你没有pip,你可以在这里得到它,它真的很有用

于 2015-01-26T13:13:07.447 回答
0
conda install -c conda-forge textblob

这在 Jupyter 环境中有效。

于 2019-12-04T21:12:11.537 回答