Open Rudra07 opened 5 years ago
VADER migrated to Python 3 a little while ago, so there may be backwards compatibility issues with Python 2.
i'm on python 3.8 still getting similar error:
anonymous@z articles % python3 sentiment.py
[nltk_data] Downloading package vader_lexicon to
[nltk_data] /Users/anonymous/nltk_data...
[nltk_data] Package vader_lexicon is already up-to-date!
Traceback (most recent call last):
File "sentiment.py", line 13, in <module>
score = sentiment().polarity_scores(headline) # run analysis
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/nltk/sentiment/vader.py", line 360, in polarity_scores
sentitext = SentiText(text, self.constants.PUNC_LIST,
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/nltk/sentiment/vader.py", line 270, in __init__
text = str(text.encode("utf-8"))
AttributeError: 'float' object has no attribute 'encode'
it's weird because i ran through a shorter csv file with no problems. it's only occurring on a much larger file.
also, this thing is really cool, thanks!
ok, i actually figured a bunch of them out. mostly regex special characters will cause errors. still have some that i can't figure out though:
anonymous@z articles % python3 sentiment.py
Traceback (most recent call last):
File "sentiment.py", line 14, in <module>
score = sentiment.polarity_scores(headline)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/nltk/sentiment/vader.py", line 360, in polarity_scores
sentitext = SentiText(text, self.constants.PUNC_LIST,
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/nltk/sentiment/vader.py", line 270, in __init__
text = str(text.encode("utf-8"))
AttributeError: 'float' object has no attribute 'encode'
if anyone knows how to get around or fix this, it'd be very very much appreciated. thank you in advance!
nevermind i got it. i didn't convert to string before analyzing.
while installing "pip install python-openstackclient " with python 2.7 it's failed with below error:
Downloading warlock-1.3.2.tar.gz Running setup.py (path:/tmp/pip_build_root/warlock/setup.py) egg_info for pack age warlock Traceback (most recent call last): File "", line 17, in
File "/tmp/pip_build_root/warlock/setup.py", line 37, in
long_description=read("README.md"),
File "/tmp/pip_build_root/warlock/setup.py", line 28, in read
os.path.join(os.path.dirname(file), fname), "r", encoding="utf-8"
TypeError: 'encoding' is an invalid keyword argument for this function
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 17, in
File "/tmp/pip_build_root/warlock/setup.py", line 37, in
File "/tmp/pip_build_root/warlock/setup.py", line 28, in read
TypeError: 'encoding' is an invalid keyword argument for this function