无法安装pip和包

时间:2018-06-04 06:41:25

标签: python python-3.x pip

我正在使用python 3.6。 Pip与python一起安装。好像pip似乎没有出现。试过这里可用的各种解决方案没有用。请帮我解决这个问题。

已完成验证 路径设置为C:\Program Files\Python36\Scripts 添加了所有3

的主机条目

PIP错误:

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.

5 个答案:

答案 0 :(得分:0)

尝试使用

pip2

对于python 2.和

pip3

对于python 3

从管理员cmd行开始。

答案 1 :(得分:0)

检查是否已添加这些目录的路径(如果您使用的是python3.x版本) - C:\ Users \ tojose \ AppData \ Local \ Programs \ Python \ Python3.x和pip C:\ Users \ tojose \ AppData \ Local \ Programs \ Python \ Python3.x \ Scripts as pip * .exe&#39; s 存储在这里。

答案 2 :(得分:0)

尝试使用pip和您要安装的软件包的完整路径。

示例(对于Python 3.6):

C:\ Python36 \ Scripts \ pip install C:\ Python36 \ requests-2.18.4-py2.py3-none-any.whl

答案 3 :(得分:0)

在Windows 10上,我遇到了同样的问题。 PIP 19已安装在我的系统中,但未显示。错误为No Module Found

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

pip降级为9.0.3对我来说很好。

我已经回答了HERE

答案 4 :(得分:0)

我遇到了同样的问题,尝试了几个命令都没有结果。我只是简单地将我的 pip 版本从 19.10 升级到了 20.3.3 版本,现在它工作正常。

python -m pip install --upgrade pip 

(适用于 Windows)

enter image description here

注意:您正在 Python REPL 中应用 pip 命令,这是错误的。 通过使用 exit() 函数从 Python 中出来并像这样写。

enter image description here

就我而言,我已经安装了新版本。

相关问题