我正在尝试将 pip 从版本 7.1.2 升级到版本 8.0.2,但是,当我在命令行中键入 python -m pip install --upgrade pip
时,它返回:
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 --version
返回:
pip 7.1.2 from C:\Users\Owner\Anaconda3\lib\site-packages (python 3.5)
我运行的是 Windows 10 64 位操作系统。
编辑:另外,当我在命令行中只输入 python
时,它返回:
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“停止工作”。
编辑 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
更改为与您的系统相似的内容。
这是暂时的,在当前 session 之后一切都将被重置。要了解更多信息,请查看 here .
来自 this为 Windows 升级 pip
的源代码,以下应该有效:
python -m pip install -U pip
关于python - 尝试升级 pip 时出现致命的 Python 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35165398/