Alex Gisi
Alex Gisi

Reputation: 93

Fatal Python error when attempting to upgrade pip

I'm trying to upgrade pip to version 8.0.2 from version 7.1.2, however, when I type python -m pip install --upgrade pip, into the command line, it returns:

Fatal Python error: Py_Initialize: unable to load the file system codec
ImportError: No module named 'encodings'

Current thread 0x00007cf8 (most recent call first):  

My pip --version returns:

pip 7.1.2 from C:\Users\Owner\Anaconda3\lib\site-packages (python 3.5)

I'm running Windows 10, 64-bit operating system.

EDIT: Additionally, when I type only python in command line, it returns:

C:\Users\Owner>python
Fatal Python error: Py_Initialize: unable to load the file system codec
ImportError: No module named 'encodings'

Current thread 0x00007cf8 (most recent call first):

And python "stops working."


EDIT 2: My PATH:

PATH=C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Python27\;C:\Python27\Scripts;C:\Program Files (x86)\Python332\;C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\MiKTeX 2.9\miktex\bin\;C:\Python334\Tools\Scripts;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files
(x86)\Skype\Phone\;C:\Users\Owner\Anaconda3;C:\Users\Owner\Anaconda3\Scripts;C:\Users\Owner\Anaconda3\Library\bin


I do have multiple versions of python installed, I realize that could contribute to the problem, but if it actually does or what to do about it.

Upvotes: 4

Views: 1502

Answers (2)

Alex Gisi
Alex Gisi

Reputation: 93

The Correct Answer

Okay, so helped by Rafael, I got this to work. What he found was that I needed to update the contents of my PATH with the location of python 3.5. Also, I had to create a new user variable called PYTHONPATH, which was directed to my libs directory.

You can see how to the menu required for this here: How to add to the pythonpath in windows 7?

Upvotes: 2

Rafael
Rafael

Reputation: 7242

Try python3 instead.

python3 -m pip install --upgrade pip

Edit:

To temporary fix the problem with your PATH enter the following commands:

C:\>set PATH=C:\Program Files\Python 3.5;%PATH%
C:\>set PYTHONPATH=%PYTHONPATH%;C:\My_python_lib
C:\>python

You should change the C:\My_python_lib to something similar for your system.

This is temporary and after the current session everything will be reset. To find more about this, have a look here.

From this source to upgrade pip for Windows, the following should work:

python -m pip install -U pip

Upvotes: 3

Related Questions