0

Very weird problem. While python and works perfectly fine, I couldn't use pipenv. I'm running it on windows, and it doesn't work on windows terminal, powershell, vscode terminal. Python version is 3.10.5, system PATH already has the folder location where python.exe is. I have also tried adding PYTHONPATH and PYTHONHOME variables but still did not work.

I'm still new at this, I tried pip uninstall pipenv, virtualenv, but when I run pipenv it still gives me the same error message and not the "not recognized as a command" error.

This is the error message when I run pipenv --version, pipenv shell, pipenv install etc.:

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 = '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\\_temp\\msys\\msys64\\mingw64'
  sys.base_exec_prefix = 'C:\\program files\\inkscape'
  sys.executable = 'C:\\program files\\inkscape\\bin\\python.exe'
  sys.prefix = 'D:\\a\\_temp\\msys\\msys64\\mingw64'
  sys.exec_prefix = 'C:\\program files\\inkscape'
  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',
    'C:\\program files\\inkscape\\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
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00006e4c (most recent call first):
<no Python frame>

I thought inkscape was the problem, so I uninstalled it, but it still doesn't work.

Please help me, thank you

mpagung
  • 1
  • 2

2 Answers2

0

This was the answer for me: Long story short, I uninstalled the python from Microsoft Store, restarted my computer, installed using the python 3.10.5 installer from python.org, made sure I check the checkbox to “add python to PATH”, restart my computer. On the terminal, run “which python” and ensure it is on the right path, which should be “c:\users\ [username]\appdata\local\programs\python\python310\python” and not on “c:\program files\windowsapp....” This should be both on the user variable and system variable for the variable “PATH” I consulted with a programmer friend and he helped me solve this issue. This is the process for troubleshooting for anyone facing similar issues as I did on Windows:

  1. Find which python, pip, and pipenv the system is using (different terminals like windows terminal, powershell, cmd prompt might have different results, so just use the one you like the most, which was for me was my modified windows terminal). The error code here only tells me the symptoms and not the actual problem. So pursuing the “encoding module not found” was actually jumping deeper into the rabbit hole. Luckily, I realized from experience that encoding was not the issue, but rather the terminal did not recognize where python or pipenv is. (I do realize that when a module or cmd is not recognized, the terminal will usually say “module not recognized” instead of the this long error prompt. So it is still a mistery to me why it did that instead of the simple “module not recognized”.
  • “Which python” shows the default python installation used, “python -V” shows which python it is associated with and the location, “pip show certifi” is for showing which python pip is using
  1. I found a discrepancy, where most of my modules use appdata, which is where normally pip installs and python.org installers use. But python was using WindowsApp because I had installed it using microsoft store. (On my defense, when you google python installer most guides will tell you to install from microsoft store, which was a rookie mistake)
  2. Uninstall the python you don’t want on “add or remove program” from windows. Then install python on its website and make sure to check the checkbox for adding the newly installed python to the system environment variable. See if it works on the terminal. Normally the computer needs to reboot to make the necessary changes.
  3. Done! If it doesn’t work, make sure to purge every python you have on the computer, install using the installer directly from the python website, and make sure the python path is added to the environment variable
mpagung
  • 1
  • 2
-1

I may not be able to answer your question but I might contribute to the solution:

1.try to find here why you get the ModuleNotFoundError: No module named 'encodings' what library are you missing ? 2. Check this older thread here it may be of help : ImportError: No module named 'encodings' 3. I used to use Pipenv in my Jupiter terminal and due to colleagues engineering choices I always had problem so decided to move to Poetry check it out is really good :https://python-poetry.org/

I may have not helped you find the answer but hopefully have made a small contribution...all debugging is like criminal investigation sometimes you need to incrementally acquire new evidence to solve crimes so ..expect lots of patience from yourself and don't get disappointed easily!