python Windows中的TextBlob安装

s2j5cfk0  于 2023-09-29  发布在  Python
关注(0)|答案(5)|浏览(155)

我已经按照Trouble installing TextBlob for Python中的说明在Windows 7中安装了TextBlob。它已经安装好了,但是当我进入Python Idle并输入import TextBlob时,它说
没有名为TextBlob的模块
如何解决这一问题?
或者我可以直接将与包关联的库放在Python Lib文件夹中,并尝试在程序中导入它吗?如果这是可取的,请告诉程序这样做。会成功吗?
任何帮助将不胜感激。

2ul0zpep

2ul0zpep1#

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

conda install -c conda-forge textblob
bvjveswy

bvjveswy2#

试试这个:

from textblob import TextBlob

来源:TextBlob package description

n8ghc7c1

n8ghc7c13#

在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...'
3htmauhk

3htmauhk4#

尝试

pip install textblob

如果你没有pip,你可以得到它here,这是非常有用

yuvru6vn

yuvru6vn5#

conda install -c conda-forge textblob

这是在一个环境下工作的。

相关问题