4

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.

dirn
  • 19,454
  • 5
  • 69
  • 74
Alex Gisi
  • 93
  • 8

2 Answers2

3

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
Rafael
  • 7,002
  • 5
  • 43
  • 52
  • This returns `'python3' is not recognized as an internal or external command, operable program or batch file.` – Alex Gisi Feb 02 '16 at 23:05
  • Can you update your questions and include your operating system as well? – Rafael Feb 02 '16 at 23:06
  • Updated, has that helped? – Alex Gisi Feb 02 '16 at 23:08
  • When you type `python` in your command prompt, what is the python's interpreter version ? – Rafael Feb 02 '16 at 23:12
  • Unforunately, using `py -3` brings me back to where I started: pip version 7.1.2 installing successfully and it giving me a recommendation to use `python -m pip install` if I want to upgrade to 8.0.2. Originally, I used `pip install --upgrade pip`, though. – Alex Gisi Feb 02 '16 at 23:15
  • I have found the following command on official documentation, `python -m pip install -U pip` (I am sorry, not Windows user, so please try and let me know) – Rafael Feb 02 '16 at 23:16
2

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?

Alex Gisi
  • 93
  • 8