Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'encoding' is an invalid keyword argument for this function #47

Closed
zHaytam opened this issue May 2, 2018 · 4 comments
Closed

'encoding' is an invalid keyword argument for this function #47

zHaytam opened this issue May 2, 2018 · 4 comments

Comments

@zHaytam
Copy link

zHaytam commented May 2, 2018

Hello,

I am trying to use vaderSentiment with Python 2.7.12 but it's giving me this error, line: https://github.com/cjhutto/vaderSentiment/blob/master/vaderSentiment/vaderSentiment.py#L212

Does vaderSentiment support python 2?
Thank you.

@cjhutto
Copy link
Owner

cjhutto commented May 2, 2018

We migrated to Python 3 a little while ago, so there may be backwards compatibility issues with Python 2. For your issue -- in Python 2, the open() function takes no encoding argument (the third argument is the buffering option instead).

The fix is to add the following line near the top of the vaderSentiment.py file:
from io import open

If you are able to make this work, let me know, and I'll update the master branch so that others will benefit from this backwards compatibility hack.

@zHaytam
Copy link
Author

zHaytam commented May 2, 2018

Hello, thank you for the fast reply.

Adding from io import open seems to fix the issue (tested on 2.7.12 and 3.6).
I ran mine using f.read().decode('UTF-8') because I didn't see your message in time, but your solution is better since it handles both versions.

Thank you!

@rxng
Copy link

rxng commented Oct 15, 2019

@cjhutto I've added that but it still comes up with this:

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

@christianoruge
Copy link

You saved my day! Including the line in my script did it! Thanks 👍

chrismattmann added a commit to chrismattmann/tika-python that referenced this issue Nov 23, 2019
@cjhutto cjhutto closed this as completed Mar 23, 2020
igodev0001 pushed a commit to igodev0001/tika-python that referenced this issue Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants