I run a .py file with Sublime Text - everything works perfect.
I run a .py file with cmd - everything works perfect.
I run a .py file with VS Code - for the first 15 seconds code works and everything is ok. If I start a code about 15 seconds after VS Code launch - I see this:
Python path configuration:
PYTHONHOME = 'C:\Users\wonka\AppData\Local\Programs\Python\Python38'
PYTHONPATH = 'C:\Users\wonka\AppData\Local\Programs\Python\Python38'
program name = 'C:\Program Files\MSYS2\mingw64\bin\python.exe'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = 'C:\\Program Files\\MSYS2\\mingw64\\bin\\python.exe'
sys.base_prefix = 'C:\\Users\\wonka\\AppData\\Local\\Programs\\Python\\Python38'
sys.base_exec_prefix = 'C:\\Users\\wonka\\AppData\\Local\\Programs\\Python\\Python38'
sys.executable = 'C:\\Program Files\\MSYS2\\mingw64\\bin\\python.exe'
sys.prefix = 'C:\\Users\\wonka\\AppData\\Local\\Programs\\Python\\Python38'
sys.exec_prefix = 'C:\\Users\\wonka\\AppData\\Local\\Programs\\Python\\Python38'
sys.path = [
'C:\\Users\\wonka\\AppData\\Local\\Programs\\Python\\Python38',
'C:\\Users\\wonka\\AppData\\Local\\Programs\\Python\\Python38\\lib\\python38.zip',
'C:\\Users\\wonka\\AppData\\Local\\Programs\\Python\\Python38\\lib\\python3.8',
'C:\\Users\\wonka\\AppData\\Local\\Programs\\Python\\Python38\\lib\\python3.8',
'C:\\Users\\wonka\\AppData\\Local\\Programs\\Python\\Python38\\lib\\python3.8\\lib-dynload',
]
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'
Current thread 0x000017b0 (most recent call first):
<no Python frame>
Also I turned off all extensions except Python - and nothing changed.
In the very left corner of VS Code window is a selector of Python version. Don't know why, but it was not selected. VS Code screenshot. You just need to click on it and select Python version.
Try uninstalling and reinstalling the IDE. Your Extension will not be affected.
Related
I recently tried adding an Xlwings add-in to my ms excel and in doing so, moved around and deleted a bunch of files in my computer. Now I can't run Conda and I get the error message below on my terminal when I try to run any kind of Conda command.
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Python path configuration:
PYTHONHOME = (not set)
PYTHONPATH = (not set)
program name = '/opt/anaconda3/bin/python'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = '/opt/anaconda3/bin/python'
sys.base_prefix = '/opt/anaconda3'
sys.base_exec_prefix = '/opt/anaconda3'
sys.platlibdir = 'lib'
sys.executable = '/opt/anaconda3/bin/python'
sys.prefix = '/opt/anaconda3'
sys.exec_prefix = '/opt/anaconda3'
sys.path = [
'/opt/anaconda3/lib/python39.zip',
'/opt/anaconda3/lib/python3.9',
'/opt/anaconda3/lib/lib-dynload',
]
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'
I saw the other post ImportError: No module named 'encodings' about this issue and tried following the instructions there but it didn't help in my case. Can someone please help with this? I've been trying to unsuccessfully solve this issue for days now and I'm all out of ideas.
Solved. The solution was to install anaconda3 using command line installer rather than graphical installer.
I had the problem with anaconda under Windows when I have an embedded python in my c++ app via Python C-API.
I had the following error, where they key was, that
c:\ProgramData\Anaconda3\python39.zip
did not exist. I created a text file of that name and that solved for me the problem.
Python path configuration:
PYTHONHOME = (not set)
PYTHONPATH = (not set)
program name = 'python'
isolated = 0
environment = 1
user site = 1
import site = 1
[...]
sys.prefix = 'c:\\ProgramData\\Anaconda3'
sys.exec_prefix = 'c:\\ProgramData\\Anaconda3'
sys.path = [
'c:\\ProgramData\\Anaconda3\\python39.zip',
'.\\DLLs',
'.\\lib',
[...],
]
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'
I did everything from these answers on a previous thread and nothing changed. Even uninstalling Python did not improve the situation. Everything was working fine but all of a sudden it stopped working.
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Python path configuration:
PYTHONHOME = (not set)
PYTHONPATH = (not set)
program name = 'python'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = 'C:\\iverilog\\gtkwave\\bin\\python.exe'
sys.base_prefix = 'D:\\a\\_temp\\msys\\msys64\\mingw64'
sys.base_exec_prefix = 'D:\\a\\_temp\\msys\\msys64\\mingw64'
sys.executable = 'C:\\iverilog\\gtkwave\\bin\\python.exe'
sys.prefix = 'D:\\a\\_temp\\msys\\msys64\\mingw64'
sys.exec_prefix = 'D:\\a\\_temp\\msys\\msys64\\mingw64'
sys.path = [
'D:\\a\\_temp\\msys\\msys64\\mingw64\\lib\\python38.zip',
'D:\\a\\_temp\\msys\\msys64\\mingw64\\lib\\python3.8',
'D:\\a\\_temp\\msys\\msys64\\mingw64\\lib\\python3.8',
'D:\\a\\_temp\\msys\\msys64\\mingw64\\lib\\lib-dynload',
]
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'
Current thread 0x000029e8 (most recent call first):
<no Python frame>
I've just had the same problem.
Looking back, the error is fairly clear: ModuleNotFoundError: No module named 'encodings' means Python is not able to find the encodings module, one of Python built-in modules. I had a look at my filesystem and found out that the encodings module is found at C:\msys64\mingw64\lib\python3.8\encodings. This meant that Python could not find that folder!
My simple solution was to add C:\msys64\mingw64\lib\python3.8 to the PYTHONPATH environment variable. On Windows you can either set it from the Windows settings UI - the permanent way - or set it temporarily from the command line, using this command: set PYTHONPATH=C:\msys64\mingw64\lib\python3.8\.
This kind of feels like a hack since, as a basic Python module, it should be found automatically and yet doesn't. However, at this point, I've had no other Python-related problems so I figure it really does the trick.
I'm quite new to programming. For the last couple of months I was working with PyCharm without any issues and also didn't do any changes (not sure if I have by accident deleted anything in Pycharm in the external libraries which may be causing any issues?).
When running python.exe via CMD I get below error. Same appears in PyCharm, only that the PYTHONPATH differs
PYTHONHOME = (not set)
PYTHONPATH = (not set)
program name = 'python.exe'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = 'C:\\Users\\LXVFL\\AppData\\Local\\Programs\\Python\\Python310\\python.exe'
sys.base_prefix = ''
sys.base_exec_prefix = ''
sys.platlibdir = 'lib'
sys.executable = 'C:\\Users\\LXVFL\\AppData\\Local\\Programs\\Python\\Python310\\python.exe'
sys.prefix = ''
sys.exec_prefix = ''
sys.path = [
'C:\\Users\\LXVFL\\AppData\\Local\\Programs\\Python\\Python310\\python310.zip',
'C:\\Users\\LXVFL\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\',
'C:\\Users\\LXVFL\\AppData\\Local\\Programs\\Python\\Python310\\DLLs\\',
'C:\\Users\\LXVFL\\AppData\\Local\\Programs\\Python\\Python310',
]
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'
Current thread 0x00002e60 (most recent call first):
<no Python frame>
What can I do here?
Thanks for any kind of help :-)
Update: What finally solved my problem was to simply deinstall and reinstall Python. Still no clue what even caused the issue in the first place but it is gone
I encountered the same problem. Reinstalling python solved mine
i've changed my windows os (install a new windows 10) on my laptop and my files from my old windows remained on my other drivers i had a django project using a virtual environment on one of them since i've installed a new windows so i installed a new Python now when i try to run my django project i get this error that i dont have python on this path and the path have the username of my old windows (i've added python in my new windows path but since the new windows user name changed i think it cause a problem):
Python path configuration:
PYTHONHOME = (not set)
PYTHONPATH = (not set)
program name = 'python'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = 'D:\\Codes\\web\\Blog.2.0\\blog2_dj\\Scripts\\python.exe'
sys.base_prefix = ''
sys.base_exec_prefix = ''
sys.executable = 'D:\\Codes\\web\\Blog.2.0\\blog2_dj\\Scripts\\python.exe'
sys.prefix = ''
sys.exec_prefix = ''
sys.path = [
'D:\\Codes\\web\\Blog.2.0\\blog2_dj\\Scripts\\python38.zip',
'.\\DLLs',
'.\\lib',
'c:\\users\\**old windows user name**\\appdata\\local\\programs\\python\\python38',
]
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'
Current thread 0x00001148 (most recent call first):
<no Python frame>
what should i do?
The issue is with the environment variables on your new windows installation.
The error you got usually happens when you have set PYTHONHOME or PYTHONPATH even though they are not needed.
In almost all cases neither of them need to be set and in the very few cases where they are needed it's almost always a mistake to set PYTHONHOME.
The solution is to remove the PYTHONHOME and/or PYTHONPATH environment variables.
Please check Christopher J answer
In my case i just simply repair python exe file from downloads
I just learned, that upon some errors, Python dumps its path configuration ; for instance, like in this snippet from Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding, when trying to start uwsgi :
!!! Python Home is not a directory: /home/env3/educ !!!
Set PythonHome to /home/env3/educ
Python path configuration:
PYTHONHOME = '/home/env3/educ'
PYTHONPATH = (not set)
program name = '/home/env3/educ/bin/python'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = '/home/env3/educ/bin/python'
sys.base_prefix = '/home/env3/educ'
sys.base_exec_prefix = '/home/env3/educ'
sys.executable = '/home/env3/educ/bin/python'
sys.prefix = '/home/env3/educ'
sys.exec_prefix = '/home/env3/educ'
sys.path = [
'/home/env3/educ/lib/python38.zip',
'/home/env3/educ/lib/python3.8',
'/home/env3/educ/lib/python3.8/lib-dynload',
]
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'
Current thread 0x00007efe89db8780 (most recent call first):
<no Python frame>
So, now I'm wondering - is there a command line switch, so I could just call, let's say something like python --dump-path-config, and it would print the above path configuration, and exit?
I am aware that one could write a Python script that would perform the same task and run that - however, since this dump is apparently "built-in" in Python anyways, I was wondering if there was a way to use that machinery.
( Btw, I found Issue 38236: Dump the Python path configuration at the first import error - Python tracker - apparently this kind of dump exists only for Python 3.8 and 3.9 )
No command line switch for this.
The "Python path configuration" is dumped from: https://github.com/python/cpython/blob/3eb2b9634fdc6826a558fa5aa820dc6e69b7800e/Python/initconfig.c#L3065
but the symbol is not exported to the ctypes.pythonapi and can't be called directly.
You must write a Python script that would perform the same task on other way.