poetry: poetry env use fails with: ModuleNotFoundError: No module named 'encodings'

  • Poetry version: 1.2.2

  • Python version: 3.10.8

  • OS version and name: Windows 11

  • pyproject.toml: n/a

  • [x ] I am on the latest stable Poetry version, installed using a recommended method.

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

  • [ x] I have consulted the FAQ and blog for any relevant entries or release notes.

  • [x ] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.

Issue

Having installed a standard, Python.org Python as well as poetry using official Powershell script, I attempt to use a separate python environment:

poetry env use /full/path/to/python

Here is the output:

Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Attempting poetry debug info generates the same error.

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 6
  • Comments: 15 (7 by maintainers)

Most upvoted comments

I also ran into this issue, I uninstalled python 3.10.8 and installed 3.11.0 using pyenv and setting it as the global interpreter. Just decided to uninstall poetry and reinstall it using the recommended method and it’s working again fine.

To further debug this, please run the command Poetry is using to introspect your Python interactively, e.g. /full/path/to/python -c "import sys; print(sys.executable)". We can then determine if something Poetry is doing to the environment image is causing the issue, or if the Python itself is the issue.

Regarding “issues,” you are the first user to run into both of the issues you’ve opened today. These are new and I (nor any other regular contributors) do not have solutions for them yet, as they are novel to us. If they truly are revealed to be common gotchas, we can certainly discuss adding FAQ entries. As things stand, Poetry is installed over a hundred thousand times a month on Windows and we have yet to see anybody reach about about the difficulties you are having.