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'
Related
So, long story short, as a young naive programmer I installed Python on the same machine too many times, to the point that it took me hours to simply do use libraries simply because they were "not found".
I decided to change that today and tried to delete all Python configurations and to a clean install of Python 3.11 on C:\Program Files\ (keep in mind I had multiple installs of Python in multiple folders) and now when trying to run python3 filename.py I get this daunting error:
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 = 'C:\msys64\mingw64\bin\python3.exe'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = 'C:\\msys64\\mingw64\\bin\\python3.exe'
sys.base_prefix = 'D:\\a\\_temp\\msys\\msys64\\mingw64'
sys.base_exec_prefix = 'D:\\a\\_temp\\msys\\msys64\\mingw64'
sys.platlibdir = 'lib'
sys.executable = 'C:\\msys64\\mingw64\\bin\\python3.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\\python39.zip',
'D:\\a\\_temp\\msys\\msys64\\mingw64\\lib\\python3.9',
'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 0x000094d8 (most recent call first):
<no Python frame>
The problem is that I have already deleted the "program name" python3.exe. I have also checked my path and I only have C:\Program Files\Python311\Scripts\ and C:\Program Files\Python311\ in regards to Python-related environment variables.
Is there a way to change the program name variable to my current directory? I believe that will solve my problems. All the best.
I tried to install the latest python version, it concluded and the path is correct in the user variables, however I can't open it in the terminal.
When I try to open I get this message:
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 = 'C:\Program Files\Inkscape\bin\python.exe'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = 'C:\\Program Files\\Inkscape\\bin\\python.exe'
sys.base_prefix = 'D:\\a\\msys64\\mingw64'
sys.base_exec_prefix = 'D:\\a\\msys64\\mingw64'
sys.platlibdir = 'lib'
sys.executable = 'C:\\Program Files\\Inkscape\\bin\\python.exe'
sys.prefix = 'D:\\a\\msys64\\mingw64'
sys.exec_prefix = 'D:\\a\\msys64\\mingw64'
sys.path = [
'D:\\a\\msys64\\mingw64\\lib\\python39.zip',
'D:\\a\\msys64\\mingw64\\lib\\python3.9',
'D:\\a\\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 0x000027c8 (most recent call first):
<no Python frame>
I also have no idea why there is a python.exe in an Inkscape folder. The previous version of python was installed there, which I also have no idea why.
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