TextBlob installation in windows

空扰寡人 提交于 2019-12-05 21:23:44

Try this:

from textblob import TextBlob

Source: TextBlob package description

In Windows, if you try installing textblob or any other packages in python, then you have to give administrative rights to the application through which you are installing the packages.

For me, it gave the same error while I was installing it through Pycharms. I gave administrative rights and it worked just fine!

pip install -U textblob
python -m textblob.download_corpora

To import just type:

from textblob import TextBlob

An example:

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...'

Install it with conda. It worked for me!

conda install -c conda-forge textblob

try

pip install textblob

if you dont have pip, you can get it here, it's really usefull

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!