poetry env use fails with: ModuleNotFoundError: No module named 'encodings'
See original GitHub issue-
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 (
-vvvoption) 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.
Issue Analytics
- State:
- Created a year ago
- Comments:14 (7 by maintainers)
Top Results From Across the Web
ImportError: No module named 'encodings' - python
For Python-3 try removing virtual environment files. ... I was facing this issue "ModuleNotFoundError: No module named 'encodings" after updating to macOS ...
Read more >No Module named “Encodings” — A common ... - faun.dev
A new window with the title “Environment Variables” will appear. Ensure that the Python path for your user variables is shown in “Path...
Read more >No Module named “Encodings” — A ... - FAUN Publication
The Solution! · When you download Python3. · Then, open system properties and navigate to the “Advanced” tab. · Ensure that the Python...
Read more >fatal python error: init_fs_encoding: failed to get the ... - You.com
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding ModuleNotFoundError: No module named 'encodings'.
Read more >PYTHON : ImportError: No module named 'encodings'
PYTHON : ImportError: No module named ' encodings ' [ Gift : Animated Search Engine : https://www.hows.tech/p/recommended.html ] PYTHON ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

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.