问题
When I try to install SenticNet for sentiment analysis using Conda it cannot find it. Then I tried pip install and I got the error:
Collecting senticnet Using cached senticnet-0.3.3.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 20, in <module>
File "C:\Users\A00220~1\AppData\Local\Temp\pip-build-ez4td4hb\senticnet\setup.py", line 20, in <module>
license=open('LICENSE').read(),
File "C:\Anaconda3\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position
181: character maps to <undefined>
I have Anaconda 64-bit, python 3.4.3 and pip 7.0.3
回答1:
This is due to Python not opening the file as UTF-8 when reading. It appears like Windows does not use Unicode by default so you have to pass in encoding='utf-8'
to the call to open. Looking at your error code, you need to change line 20 in setup.py
to
license=open('LICENSE', encoding='utf-8').read()
For more information, checkout Python's Unicode HOWTO specifically the reading and writing of data.
回答2:
Clone the github repository from:
https://github.com/yurimalheiros/senticnetapi
After unzipping the file, open setup.py and replace line number 20 with:
license=open('LICENSE', encoding='utf-8').read()
after this, open command prompt here(make sure you have environment variable set for python)
run the command -> 'python setup.py install'
This will install senticnet for python, now to get it running in Anaconda, copy the following folder:
C:\Users\HP\AppData\Local\Programs\Python\Python36-32\Lib\site-packages\senticnet-1.3-py3.6.egg\senticnet
to:
C:\Users\HP\Anaconda4\Lib\site-packages\senticnet (the path will be different based upon your configurations)
来源:https://stackoverflow.com/questions/30796090/installing-senticnet-package-on-anaconda-gives-unicodedecodeerror