I've been desperately trying to solve my problem by my own, looking some information on the Internet. However, none of them can solve my problem. I've been programming for 2-3 years, this is my first time seeing this error. I can't do any programming without solving it.
The following is my error when I type "pip3 install codecs" (or type pip install also ran the same error).
Could not find platform independent libraries <prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Python path configuration:
PYTHONHOME = (not set)
PYTHONPATH = (not set)
program name = '/Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = '/Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8'
sys.base_prefix = '/Library/Frameworks/Python.framework/Versions/3.8'
sys.base_exec_prefix = '/Library/Frameworks/Python.framework/Versions/3.8'
sys.executable = '/Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8'
sys.prefix = '/Library/Frameworks/Python.framework/Versions/3.8'
sys.exec_prefix = '/Library/Frameworks/Python.framework/Versions/3.8'
sys.path = [
'/Library/Frameworks/Python.framework/Versions/3.8/lib/python38.zip',
'/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8',
'/Library/Frameworks/Python.framework/Versions/3.8/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
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/encodings/__init__.py", line 31, in <module>
ModuleNotFoundError: No module named 'codecs'
I need help, thanks!!!
Related
Something was wrong with my Python installation so I tried to fix it by uninstalling and reinstalling Python. I've tried to do so several times, but whenever I type "python" into my terminal, I get this nasty 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 = 'C:\Users\jeffrey\AppData\Local\Programs\Python\Python39\'
program name = 'python'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = 'C:\\msys64\\mingw64\\bin\\python.exe'
sys.base_prefix = 'D:\\a\\msys64\\mingw64'
sys.base_exec_prefix = 'D:\\a\\msys64\\mingw64'
sys.platlibdir = 'lib'
sys.executable = 'C:\\msys64\\mingw64\\bin\\python.exe'
sys.prefix = 'D:\\a\\msys64\\mingw64'
sys.exec_prefix = 'D:\\a\\msys64\\mingw64'
sys.path = [
'C:\\Users\\jeffrey\\AppData\\Local\\Programs\\Python\\Python39\\',
'D:\\a\\msys64\\mingw64\\lib\\python310.zip',
'D:\\a\\msys64\\mingw64\\lib\\python3.10',
'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 0x00006b50 (most recent call first):
<no Python frame>
Is there a way to uninstall everything and get a fresh Python installation? I'm on Windows.
I've tried uninstalling Python using the control panel, manually deleting the files myself, and I've removed Python from the PATH each time.
Env:Win7 python38
I used to lunch the prompt script in start menu. Today It tells me a encoding error and spyder is not working too. How to fix it?
Python path configuration:
PYTHONHOME = (not set)
PYTHONPATH = (not set)
program name = 'd:\ProgramData\Anaconda3\python.exe'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = '\u0158E'
sys.base_prefix = '.'
sys.base_exec_prefix = '.'
sys.executable = '\u0158E'
sys.prefix = '.'
sys.exec_prefix = '.'
sys.path = [
'd:\\ProgramData\\Anaconda3\\python38.zip',
'.\\DLLs',
'.\\lib',
'',
]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the file
system encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00001f94 (most recent call first):
<no Python frame>
I have one file with my own utils I use in many projects. In order not to copy it to every single project and manually pip install everything needed, I decided to make module out of it.
However, when I use PyInstaller to create .exe file from project and try to run it, I get error:
Python path configuration:
PYTHONHOME = 'C:\Users\Adam\AppData\Local\Temp\_MEI102882'
PYTHONPATH = (not set)
program name = 'C:\Users\Adam\Desktop\Praca\TEST\dist\main.exe'
isolated = 0
environment = 0
user site = 0
import site = 0
sys._base_executable = 'C:\\Users\\Adam\\Desktop\\Praca\\TEST\\dist\\main.exe'
sys.base_prefix = ''
sys.base_exec_prefix = ''
sys.platlibdir = 'lib'
sys.executable = 'C:\\Users\\Adam\\Desktop\\Praca\\TEST\\dist\\main.exe'
sys.prefix = ''
sys.exec_prefix = ''
sys.path = [
'C:\\Users\\Adam\\AppData\\Local\\Temp\\_MEI102882\\base_library.zip',
'C:\\Users\\Adam\\AppData\\Local\\Temp\\_MEI102882\\lib-dynload',
'C:\\Users\\Adam\\AppData\\Local\\Temp\\_MEI102882',
]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
LookupError: unknown encoding: utf-8
Current thread 0x000022ac (most recent call first):
<no Python frame>
I'm not even sure what to do now. I see that some paths refer to Temp folder, don't know, however, if this is how it should be.
I am working in Windows 11, Python 3.10, Mu 1.1.0. I followed the instructions on ATBS to create a batch file to run a script from the WIN + R launcher. However in CMD the error A(below) pops up. I tried following instructions from the documentation on python.org, and in Appendix B of ATBS to edit environment variables. I added the following to PATH env variables: C:\Users\19139\MyPythonScript; C:\Users\19139\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.10\Python 3.10 (64-bit).lnk; and C:\Users\19139\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Python 3.10\Python 3.10 (64-bit).lnk\Scripts. Is there some issue with the fact that the PATH includes start menu? All I am able to call from CMD is py --version. When I try and directly call a python script I get Error B. I disabled the "App Installer"(s) under App Aliases for Python.exe and Python3.exe but no change in error. I can call py --version, but I am beyond the scope of my ability to figure out what to do. I am unsure of next possible step to problem solve, suggestions welcome.
Error A:
`enter code here`Python path configuration:
PYTHONHOME = (not set)
PYTHONPATH = (not set)
program name = 'C:\Users\19139\AppData\Local\Programs\Python\Python310\python.exe'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = 'C:\\Users\\19139\\AppData\\Local\\Programs\\Python\\Python310\\python.exe'
sys.base_prefix = ''
sys.base_exec_prefix = ''
sys.platlibdir = 'lib'
sys.executable = 'C:\\Users\\19139\\AppData\\Local\\Programs\\Python\\Python310\\python.exe'
sys.prefix = ''
sys.exec_prefix = ''
sys.path = [
'C:\\Users\\19139\\AppData\\Local\\Programs\\Python\\Python310\\python310.zip',
'C:\\Users\\19139\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\',
'C:\\Users\\19139\\AppData\\Local\\Programs\\Python\\Python310\\DLLs\\',
'C:\\Users\\19139\\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
Traceback (most recent call last):
File "C:\Users\19139\AppData\Local\Programs\Python\Python310\Lib\encodings\__init__.py", line 31, in <module>
ModuleNotFoundError: No module named 'codecs'
Error B
C:\Users\19139>python "C:\Users\19139\MyPythonScript\mClip.py"
Python was not found; run without arguments to install from the Microsoft Store, or
disable this shortcut from Settings > Manage App Execution Aliases.
First of all, unlike ubuntu/ linux Windows doesn't detect python on its own. That's why we need to specify the path manually, to make it aware of python.
Is there some issue with the fact that the PATH includes start menu?
Yes, there is issue there. PATH for python doesn't include Start Menu generally.
You are looking at the wrong place or have installed python package at the wrong location. Find the correct python package location.
Python PATH looks something like this:
C:\Users\user_name\python_installerpkg_name
For example, if you have installed python using a python installer pkg like anaconda/ mini-conda, you can use its command prompt to find the location via where python. Then use the location to set the PATH in environment variables. the PATH would look like: C:\Users\user_name\anaconda
Error B
Until you configure the correct path in the environment variables you won't be able to use the command python filename.py from the command line.
I've set up a virtual environment on MacOS BigSur 11.6 using python 3.9.7 version.
Environment name is "ambiente" and this is how the terminal looks like :
(ambiente) mac.fede#Ahoga PageDownloader %
I'm in PageDownloader directory.
Inside this folder there is my python project.
I can run the program using : python3 PageDownloader.py and all works fine.
I tried to install and run it using PyInstaller and the UNIX executable works fine.
Then using Platypus I bottled it to an application, when the icon is double clicked a shell script runs and launches the UNIX executable file obtained before.
When I double click the application this is the output :
initializing script //this launches PageDownloader Executable file
Python path configuration:
PYTHONHOME = '/Users/mac.fede/Documents/GitHub/PageDownloader/PageDownloader.app/Contents/Resources'
PYTHONPATH = (not set)
program name = '/Users/mac.fede/Documents/GitHub/PageDownloader/PageDownloader.app/Contents/Resources/PageDownloader'
isolated = 0
environment = 0
user site = 0
import site = 0
sys._base_executable = '/Users/mac.fede/Documents/GitHub/PageDownloader/PageDownloader.app/Contents/Resources/PageDownloader'
sys.base_prefix = ''
sys.base_exec_prefix = ''
sys.platlibdir = 'lib'
sys.executable = '/Users/mac.fede/Documents/GitHub/PageDownloader/PageDownloader.app/Contents/Resources/PageDownloader'
sys.prefix = ''
sys.exec_prefix = ''
sys.path = [
'/Users/mac.fede/Documents/GitHub/PageDownloader/PageDownloader.app/Contents/Resources/base_library.zip',
'/Users/mac.fede/Documents/GitHub/PageDownloader/PageDownloader.app/Contents/Resources/lib-dynload',
'/Users/mac.fede/Documents/GitHub/PageDownloader/PageDownloader.app/Contents/Resources',
]
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 0x000000010c0cfe00 (most recent call first):
<no Python frame>
Other posts on StackOverflow like this : Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding, when trying to start uwsgi
Suggests to remove the PYTHONHOME environment variable but I don't know how to do it. I can see that it's set and shouldn't. I did some researches on the internet but I didn't understand how to do this on Mac. I already tried :
unset PYTHONPATH
unset PYTHONHOME
Before launching the executable file but same error.
Now, I don't know if this is the right way to create an exportable application from python program on MacOS, I'm trying to figure it out so all this solution is "home made". If you have any suggestion I would be very happy to hear it.
With "exportable" I mean an application that I can share with my friends or other people and runnable with a double click.