获取在Windows 10上安装pip的AssertionError消息

时间:2017-01-16 23:43:00

标签: python

在下载get-pip.py尝试安装并在Windows 10中打开cmd窗口后,当我输入pip并点击回车时收到以下错误消息:

    Microsoft Windows [Version 10.0.10240]
(c) 2015 Microsoft Corporation. All rights reserved.

C:\Users\adamh>pip
Traceback (most recent call last):
  File "C:\Users\adamh\AppData\Local\Programs\Python\Python35\lib\runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\adamh\AppData\Local\Programs\Python\Python35\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\adamh\AppData\Local\Programs\Python\Python35\Scripts\pip.exe\__main__.py", line 5, in <module>
  File "C:\Users\adamh\AppData\Local\Programs\Python\Python35\lib\site-packages\pip\__init__.py", line 26, in <module>
    from pip.utils import get_installed_distributions, get_prog
  File "C:\Users\adamh\AppData\Local\Programs\Python\Python35\lib\site-packages\pip\utils\__init__.py", line 27, in <module>
    from pip._vendor import pkg_resources
  File "C:\Users\adamh\AppData\Local\Programs\Python\Python35\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 70, in <module>
    from pip._vendor import appdirs
  File "C:\Users\adamh\AppData\Local\Programs\Python\Python35\lib\site-packages\pip\_vendor\appdirs.py", line 510, in <module>
    import win32com.shell
  File "C:\Users\adamh\AppData\Local\Programs\Python\Python35\lib\site-packages\win32com\__init__.py", line 6, in <module>
    import pythoncom
  File "C:\Users\adamh\AppData\Local\Programs\Python\Python35\lib\site-packages\pythoncom.py", line 2, in <module>
    import pywintypes
  File "C:\Users\adamh\AppData\Local\Programs\Python\Python35\lib\site-packages\win32\lib\pywintypes.py", line 124, in <module>
    __import_pywin32_system_module__("pywintypes", globals())
  File "C:\Users\adamh\AppData\Local\Programs\Python\Python35\lib\site-packages\win32\lib\pywintypes.py", line 117, in __import_pywin32_system_module__
    assert sys.modules[modname] is not old_mod
AssertionError

C:\Users\adamh>

我尝试了所有的升级,但是没有一个升级成功。非常感谢您提供的任何帮助。真诚的,will_learn

1 个答案:

答案 0 :(得分:0)

首先从命令提示符检查你的python是否正常运行。

打开命令提示符并运行python它应该显示你的python版本,否则正确安装它并在环境变量中添加它的路径

大多数Pip应该已经包含在Python 2.7.9+或3.4+中,但如果出于任何原因它不存在,你可以使用以下单行。

下载https://bootstrap.pypa.io/get-pip.py并使用管理员权限python get-pip.py运行它(如果你在Linux上,请使用sudo python get-pip.py)

您必须将pip的路径添加到环境变量中。 Pip包含在python的脚本目录中。

我的案例:C:\ Python35 \ Scripts \ pip.exe

添加环境变量的路径。

Hold Win and press Pause.
Click Advanced System Settings.
Click Environment Variables.
Add C:\Python35\Scripts (Sorry I don't know name of python 3.5's directory) to the Path on System variables.
Restart Command Prompt.
Edit

另一方面,您可以使用pip-Win而不是pip。在此处阅读更多内容:https://sites.google.com/site/pydatalog/python/pip-for-windows