2

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?

Roxana
  • 345
  • 1
  • 2
  • 9
  • 1
    you are missing a module name encodings. Check this answer https://stackoverflow.com/questions/38132755/importerror-no-module-named-encodings –  Feb 15 '22 at 12:15
  • @SembeiNorimaki thanks but the answer that you mentioned is a bit confusing would you please tell me what commands should i use and if i use them will it affect my Django codes or not? – Roxana Feb 15 '22 at 12:39

3 Answers3

1

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

0

In my case i just simply repair python exe file from downloads

0

When I encountered the same issue, I simply pressed "ctrl+shift+p" (vscode) and chose the correct version of python. According to my understanding, it informs the program of its location within the system files.