classification
Title: Python not working on Windows 10
Type: behavior Stage: resolved
Components: Windows Versions: Python 3.8
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: eryksun, methane, paul.moore, rafaeldominiquini, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2019-12-15 02:13 by rafaeldominiquini, last changed 2019-12-15 21:51 by rafaeldominiquini. This issue is now closed.

Messages (15)
msg358411 - (view) Author: Rafael Dominiquini (rafaeldominiquini) Date: 2019-12-15 02:13
I have Python installed on my computer for a while now and everything worked fine. But today, I can't run it anymore:


    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 0x00007e84 (most recent call first):
    <no Python frame>


I have already tried to download the installer and use the "Repair" option, but even though the installation indicates that everything is fine, the error continue...

Attached is the complete terminal output:

https://pastebin.com/fcFZkUSV
https://pastebin.com/Nx9J4fPu

SO: Windows 10
Python Version: 3.8.0 (64 bits)

Thanks.
msg358414 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2019-12-15 08:58
The most common cause of this error is the PYTHONPATH and PYTHONHOME environment variables.

You can see what environment variables are set by the "set" command.
msg358417 - (view) Author: Rafael Dominiquini (rafaeldominiquini) Date: 2019-12-15 11:36
* PYTHONHOME = (not set)
* PYTHONPATH = 'C:\Developing\Python;C:\Developing\Python\Scripts;C:\Developing\Python\Lib;C:\Developing\Python\Lib\site-packages;C:\Developing\Python\DLLs;'

-- I try to set the variable 'PYTHONHOME=C:\Developing\Python', but the same error appear!

Thanks
msg358418 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2019-12-15 12:07
Where did you install the portion?

What is in the C:\Developing\Python and C:\Developing\Python\Lib?

What happen when you unset both environment variables?

Do you use any antivirus software?
msg358425 - (view) Author: Rafael Dominiquini (rafaeldominiquini) Date: 2019-12-15 12:51
"C:\Developing\Python" is where I installed Python, selecting it in the installer. This directory is where the binary 'python.exe' is located!
"C:\Developing\Python\Lib" have the folders:

idlelib
site-packages
test
tkinter
turtledemo

When I unset both variables, the same error occurs:

-----
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:\\Developing\\Python\\python.exe'
  sys.base_prefix = ''
  sys.base_exec_prefix = ''
  sys.executable = 'C:\\Developing\\Python\\python.exe'
  sys.prefix = ''
  sys.exec_prefix = ''
  sys.path = [
    'C:\\Developing\\Python\\python38.zip',
    'C:\\Developing\\Python\\python-3.8.0.amd64\\Lib\\',
    'C:\\Developing\\Python\\python-3.8.0.amd64\\Lib\\lib-tk',
    'C:\\Developing\\Python\\python-3.8.0.amd64\\DLLs\\',
    'C:\\Developing\\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 0x000060e8 (most recent call first):
<no Python frame>
-----
msg358426 - (view) Author: Rafael Dominiquini (rafaeldominiquini) Date: 2019-12-15 13:01
There are other Python installations on my computer, embedded in other application installations (GIMP, etc ...), and these seem to be working normally. But they are all older versions of Python...
I haven't tried reinstalling again since I didn't want to have to reinstall all packages I currently have installed using 'pip'
msg358427 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2019-12-15 13:01
Many files and directories in the "C:\Developing\Python\Lib" are disappeared.
I don't know why.  But since you tried clean install, I suppose your antivirus killed Python.
msg358429 - (view) Author: Rafael Dominiquini (rafaeldominiquini) Date: 2019-12-15 13:05
I don't tried clean install! I tried to use the option "Repair" from the installer.
Later I will try to completely uninstall and install from scratch.
msg358430 - (view) Author: Rafael Dominiquini (rafaeldominiquini) Date: 2019-12-15 13:06
In this folder ("C: \ Developing \ Python \ Lib") there are only the folders I have listed. No other files...
msg358431 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2019-12-15 13:26
> * PYTHONPATH = 'C:\Developing\Python;C:\Developing\Python\Scripts;
> C:\Developing\Python\Lib;C:\Developing\Python\Lib\site-packages;
> C:\Developing\Python\DLLs;'

FYI, none of this should set here. For a standard configuration, the installation directory should never be in the PYTHONPATH environment variable -- including the standard library (Lib & DLLs), site-packages, and Scripts.

> I haven't tried reinstalling again since I didn't want to have to 
> reinstall all packages I currently have installed using 'pip'

The existing site-packages and Scripts directories should remain if you reinstall to "C:\Developing\Python". Either way, you don't really have a choice. The installation is broken.
msg358433 - (view) Author: Paul Moore (paul.moore) * (Python committer) Date: 2019-12-15 13:40
> sys.path = [
>    'C:\\Developing\\Python\\python38.zip',
>    'C:\\Developing\\Python\\python-3.8.0.amd64\\Lib\\',
>    'C:\\Developing\\Python\\python-3.8.0.amd64\\Lib\\lib-tk',
>    'C:\\Developing\\Python\\python-3.8.0.amd64\\DLLs\\',
>    'C:\\Developing\\Python',

The subdirectory python-3.8.0.amd64 in the various paths above should not be present, and would not be in a normal clean Python installation. It appears that somehow your installation has been corrupted.

I would recommend a clean install. if that doesn't work, it's likely that some environment variables or registry paths in your system are set incorrectly (or at least, in ways the standard installation is not expecting).
msg358434 - (view) Author: Paul Moore (paul.moore) * (Python committer) Date: 2019-12-15 13:41
Can you also confirm that the installation of Python was done with the standard Python installer from the python.org website, and is not another distribution (such as Anaconda)?
msg358446 - (view) Author: Rafael Dominiquini (rafaeldominiquini) Date: 2019-12-15 20:56
1) I tried to clear the value of the variable 'PYTHONPATH', and the error keeps happening!
2) In my installation directory, I don't have the file 'C:\Developing\Python\python38.zip', neither the directory 'C:\Developing\Python\python-3.8.0.amd64\'. I don't know why this message appears!
3) I use the installer from python.org (https://www.python.org/downloads/release/python-380/), but I got the 64-bit installer!

I will try to do a clear install later.

Thanks
msg358448 - (view) Author: Rafael Dominiquini (rafaeldominiquini) Date: 2019-12-15 21:46
I reinstall python here from scratch and now is working. But I need to delete the remaining files after the uninstall. When I tried to uninstall and reinstall holding the existing directories (\Lib\site-packages), the installer fail to copy the missing files to the installation directory.

Thanks
msg358449 - (view) Author: Rafael Dominiquini (rafaeldominiquini) Date: 2019-12-15 21:51
I probably unintentionally deleted some necessary files here on my machine. I closed the issue and marked 'not a bug'.

Thanks
History
Date User Action Args
2019-12-15 21:51:49rafaeldominiquinisetmessages: + msg358449
2019-12-15 21:50:07rafaeldominiquinisetstatus: open -> closed
resolution: not a bug
stage: resolved
2019-12-15 21:46:37rafaeldominiquinisetmessages: + msg358448
2019-12-15 20:56:43rafaeldominiquinisetmessages: + msg358446
2019-12-15 13:41:56paul.mooresetmessages: + msg358434
2019-12-15 13:40:54paul.mooresetmessages: + msg358433
2019-12-15 13:26:33eryksunsetnosy: + eryksun
messages: + msg358431
2019-12-15 13:06:19rafaeldominiquinisetmessages: + msg358430
2019-12-15 13:05:00rafaeldominiquinisetmessages: + msg358429
2019-12-15 13:01:54methanesetmessages: + msg358427
2019-12-15 13:01:53rafaeldominiquinisetmessages: + msg358426
2019-12-15 12:51:40rafaeldominiquinisetmessages: + msg358425
2019-12-15 12:07:24methanesetmessages: + msg358418
2019-12-15 11:36:36rafaeldominiquinisetmessages: + msg358417
2019-12-15 08:58:50methanesetnosy: + methane
messages: + msg358414
2019-12-15 02:13:14rafaeldominiquinicreate