首页 > 解决方案 > 无法安装 pip 和软件包

问题描述

我正在使用python 3.6。Pip 与 python 一起安装。似乎 pip 没有出现。在这里尝试了各种可用的解决方案,但没有任何效果。请帮我解决这个问题。

验证完成: 路径设置C:\Program Files\Python36\Scripts 为所有 3 个添加的主机条目

画中画错误:

C:\Users\>pip
Traceback (most recent call last):
  File "c:\program files\python36\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\program files\python36\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\Python36\Scripts\pip.exe\__main__.py", line 5, in <module>
ImportError: cannot import name 'main'

尝试过的解决方案:

pip install --trusted-host pypi.python.org --trusted-host pypi.org --trusted-host files.pythonhosted.org {package name}

C:\Users\>pip
Traceback (most recent call last):
  File "c:\program files\python36\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\program files\python36\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\Python36\Scripts\pip.exe\__main__.py", line 5, in <module>
ImportError: cannot import name 'main'

C:\Users>python3 -m pip uninstall pip setuptools
'python3' is not recognized as an internal or external command,
operable program or batch file.

C:\Users>python
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> python3 -m pip uninstall pip setuptools
  File "<stdin>", line 1
    python3 -m pip uninstall pip setuptools
                 ^
SyntaxError: invalid syntax
>>> python3 -m pip uninstall pip setuptools
  File "<stdin>", line 1
    python3 -m pip uninstall pip setuptools
                 ^
SyntaxError: invalid syntax
>>> pip install --trusted-host pypi.python.org --trusted-host pypi.org --trusted-host files.pythonhosted.org {package name}
  File "<stdin>", line 1
    pip install --trusted-host pypi.python.org --trusted-host pypi.org --trusted-host files.pythonhosted.org {package name}
              ^
SyntaxError: invalid syntax
>>>

使用以下版本

C:\Users\>python
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

标签: pythonpython-3.xpip

解决方案


在 Windows 10 上,我遇到了同样的问题。PIP 19已经安装在我的系统中,但没有出现。错误是No Module Found

python -m pip uninstall pip
python -m pip install pip==9.0.3

降级pip到 9.0.3 对我来说效果很好。

我已经在这里回答了


推荐阅读