尝试升级 pip 时出现致命 Python 错误

Fatal Python error when attempting to upgrade pip

我正在尝试将 pip 从版本 7.1.2 升级到版本 8.0.2,但是,当我在命令行中键入 python -m pip install --upgrade pip 时,它 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):  

我的pip --versionreturns:

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

我是运行Windows10、64位操作系统

编辑:另外,当我在命令行中只输入 python 时,它 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):

和python"stops working."


编辑 2:我的路径:

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


我确实安装了 python 的多个版本,我意识到这可能会导致问题,但如果确实如此或如何解决。

试试 python3

python3 -m pip install --upgrade pip

编辑:

要临时解决您的 PATH 问题,请输入以下命令:

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

您应该将 C:\My_python_lib 更改为适合您的系统的类似内容。

这是暂时的,在当前会话之后一切都将被重置。要了解更多信息,请查看 here.

this 源升级 pip 到 Windows,以下应该有效:

python -m pip install -U pip

正确答案

好的,在 Rafael 的帮助下,我让它工作了。他发现我需要用 python 3.5 的位置更新我的 PATH 的内容。此外,我还必须创建一个名为 PYTHONPATH 的新用户变量,它指向我的 libs 目录。

您可以在此处查看如何访问所需的菜单:How to add to the pythonpath in windows 7?