5

Windows 7 に TextBlob をインストールするために Python 用の TextBlob をインストールする際のトラブルの指示に従いました。インストールされましたが、Python Idle に移動して入力import TextBlobすると、

TextBlob という名前のモジュールはありません

この問題を解決するには?

または、パッケージに関連付けられているライブラリを Python Lib フォルダーに直接配置して、プログラムにインポートすることはできますか? それが望ましい場合は、それを行う手順を教えてください。それはうまくいきますか?

どんな助けでも大歓迎です。

4

5 に答える 5

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 に答える
3

これを試して:

from textblob import TextBlob

ソース: TextBlob パッケージの説明

于 2014-07-04T13:11:04.793 に答える