Giter Site home page Giter Site logo

Comments (5)

cjhutto avatar cjhutto commented on July 21, 2024 7

try adding this to your list of imports to make it backward compatible for Python 2.7:

from io import open

from vadersentiment.

rxng avatar rxng commented on July 21, 2024 1

I am facing this issue as well.

from io import open

This gets rid of the message

with open(lexicon_full_filepath, encoding='utf-8') as f:

But then now the error is showing for

File "/usr/local/lib/python2.7/dist-packages/vaderSentiment/vaderSentiment.py", line 212, in init
lexicon_full_filepath = os.path.join(os.path.dirname(this_module_file_path), lexicon_file)
TypeError: 'encoding' is an invalid keyword argument for this function

from vadersentiment.

esitharth avatar esitharth commented on July 21, 2024

Thank you for your quick response. Did that. Worked like a charm.

from vadersentiment.

Kprzeorski avatar Kprzeorski commented on July 21, 2024
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
from io import open
analyzer = SentimentIntensityAnalyzer()

ERROR:

TypeErrorTraceback (most recent call last)
<ipython-input-8-c96d329cbe73> in <module>()
      1 from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
      2 from io import open
----> 3 analyzer = SentimentIntensityAnalyzer()

/home/kap/anaconda3/envs/py36/lib/python2.7/site-packages/vaderSentiment/vaderSentiment.pyc in 
__init__(self, lexicon_file, emoji_lexicon)
    210         _this_module_file_path_ = os.path.abspath(getsourcefile(lambda: 0))
    211         lexicon_full_filepath = os.path.join(os.path.dirname(_this_module_file_path_), lexicon_file)
--> 212         with open(lexicon_full_filepath, encoding='utf-8') as f:
    213             self.lexicon_full_filepath = f.read()
    214         self.lexicon = self.make_lex_dict()

TypeError: 'encoding' is an invalid keyword argument for this function

I tried running the 3 line code inside a Jupyter notebook with python 3.6 and outside of jupyter in a terminal within python 2.7 and produced the same error. I used Ubuntu OS. Maybe put 'from io import open' in the vaderSentiment.py file? I would need instructions to produce complied bytecode to overwrite the existing one..... I've never done that before. Any suggestions or solutions?

from vadersentiment.

sunit1409 avatar sunit1409 commented on July 21, 2024

sudo nano /home/kap/anaconda3/envs/py36/lib/python2.7/site-packages/vaderSentiment/vaderSentiment.py

put from io import open in this file not on yours

from vadersentiment.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.