Completely Remove Python-Related Files Windows - python

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.

Related

How to fix anaconda prompt failure with init_fs_encoding error

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>

No module named 'codecs' ---Mac

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!!!

Python error: ModuleNotFound: encodings which does in fact exist

I have Python (3.9) installed to to my local user account programs folder. When I execute it, I get the following error. A few things that are odd:
In my main Python script, I cannot even do a simple print() first thing, so the problem is directly with Python itself
sys.path has 2 entries that don't exist. I am not sure how they were set to those values, or what set them, but they are wrong as those paths don't exist and a third entry references a zip file, which is probably related to the issue I am having
I inspected all the paths manually and everything is as it should be, and the encodings module does exist
Python only exists in my PATH environment variable once, which is:
C:\Users\<username>\AppData\Local\Programs\Python\Launcher\ and that Launcher folder doesn't exist, and I have no idea how it was even set as I intentionally told Python not to add itself to the PATH variable so it would never interfere with other Python installations (which there currently are none).
Python path configuration:
PYTHONHOME = (not set)
PYTHONPATH = (not set)
program name = 'C:\Users\<username>\AppData\Local\Programs\Python\python.exe'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = 'C:\\Users\\<username>\\AppData\\Local\\Programs\\Python\\python.exe'
sys.base_prefix = ''
sys.base_exec_prefix = ''
sys.platlibdir = 'lib'
sys.executable = 'C:\\Users\\<username>\\AppData\\Local\\Programs\\Python\\python.exe'
sys.prefix = ''
sys.exec_prefix = ''
sys.path = [
'C:\\Users\\<username>\\AppData\\Local\\Programs\\Python\\python39.zip',
'C:\\Python39\\Lib\\',
'C:\\Python39\\DLLs\\',
'C:\\Users\\<username>\\AppData\\Local\\Programs\\Python',
]
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 0x000071d4 (most recent call first):
<no Python frame>
If sys.path is incorrect (which it appears as such), how can I manually set this, or fix it? Especially given that my script never gets the opportunity to execute
I had a similar problem in which I wanted to use my Ubuntu python installed in /usr/bin but when I typed python, the default python was pointing to Anaconda python installation instead of the python installed in /usr/bin.
I solved that using this:
Use the default Python rather than the Anaconda installation when called from the terminal
So in file ~/.bashrc instead of
Added by the Anaconda3 4.3.0 installer
export PATH="/home/user/anaconda3/bin:$PATH"
one would use
export PATH="$PATH:/home/user/anaconda3/bin"

PyInstaller and custom module

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.

Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding Mac

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.

Categories