question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Poetry raises a [TypeError]'encoding' is an invalid keyword argument for this function when running in Python2.7 virtual environment

See original GitHub issue
  • I am on the latest Poetry version.

  • I have searched the issues of this repo and believe that this is not a duplicate.

  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

  • OS version and name: Ubuntu 18.04

  • Poetry version: 0.12.17

  • Link of a Gist with the contents of your pyproject.toml file: I am not allowed due to company rules

Issue

When running poetry (command: poetry update) from within a 2.7 virtual environment while parsing a package defined as a git repository the following error occurs:

[TypeError]                                     
'encoding' is an invalid keyword argument for this function  

when run with the -vvv option I get the following:

Exception trace:
 /home/mroscoe/.poetry/lib/poetry/_vendor/py2.7/cleo/application.py in run() at line 94
   status_code = self.do_run(input_, output_)
 /home/mroscoe/.poetry/lib/poetry/console/application.py in do_run() at line 88
   return super(Application, self).do_run(i, o)
 /home/mroscoe/.poetry/lib/poetry/_vendor/py2.7/cleo/application.py in do_run() at line 197
   status_code = command.run(input_, output_)
 /home/mroscoe/.poetry/lib/poetry/console/commands/command.py in run() at line 77
   return super(BaseCommand, self).run(i, o)
 /home/mroscoe/.poetry/lib/poetry/_vendor/py2.7/cleo/commands/base_command.py in run() at line 146
   status_code = self.execute(input_, output_)
 /home/mroscoe/.poetry/lib/poetry/_vendor/py2.7/cleo/commands/command.py in execute() at line 107
   return self.handle()
 /home/mroscoe/.poetry/lib/poetry/console/commands/update.py in handle() at line 41
   return installer.run()
 /home/mroscoe/.poetry/lib/poetry/installation/installer.py in run() at line 73
   self._do_install(local_repo)
 /home/mroscoe/.poetry/lib/poetry/installation/installer.py in _do_install() at line 290
   self._execute(op)
 /home/mroscoe/.poetry/lib/poetry/installation/installer.py in _execute() at line 306
   getattr(self, "_execute_{}".format(method))(operation)
 /home/mroscoe/.poetry/lib/poetry/installation/installer.py in _execute_install() at line 331
   self._installer.install(operation.package)
 /home/mroscoe/.poetry/lib/poetry/installation/pip_installer.py in install() at line 35
   self.install_git(package)
 /home/mroscoe/.poetry/lib/poetry/installation/pip_installer.py in install_git() at line 230
   self.install_directory(pkg)
 /home/mroscoe/.poetry/lib/poetry/installation/pip_installer.py in install_directory() at line 196
   with open(setup, "w", encoding="utf-8") as f:

I was able to resolve the issue by adding the following import to the pip_installer.py file:

from io import open

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
v5y8commented, May 26, 2020

I also ran into this issue, on Poetry version 1.0.5 on Ubuntu 18.04 and running poetry inside a conda environment.

Apparently this can be caused by an outdated msgback-python package documented here and here.

I was able to solve this by running pip install --upgrade --user msgpack-python.

4reactions
badrobitcommented, Nov 14, 2019

Yes it is still relevant and needs to be fixed

Read more comments on GitHub >

github_iconTop Results From Across the Web

Poetry raises a [TypeError]'encoding' is an invalid keyword ...
Poetry raises a [TypeError]'encoding' is an invalid keyword argument for this function when running in Python2.7 virtual environment #1290.
Read more >
TypeError: 'encoding' is an invalid keyword argument for this ...
The terminal you are trying to run this on probably uses Python 2.x as standard. Try using the command "Python3" specifically in the ......
Read more >
'encoding\' is an invalid keyword argument for this function ...
I have a tine code snippet and it gives me the following error: TypeError: 'encoding' is an invalid keyword argument for this function....
Read more >
Python error TypeError encoding is an invalid keyword ...
I have a tine code snippet and it gives me the following error: TypeError: 'encoding' is an invalid keyword argument for this function....
Read more >
Source code for xonsh.__amalgam
ArgumentParser ": """A bare-bones argparse builder from functions""" doc = get_doc(func) ... description="Python virtual environment manager for xonsh.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found