简体   繁体   English

Windows 10 - python pip 不工作(添加了环境变量)

[英]Windows 10 - python pip not working (with env vars added)

On Windows 10, with both Python 2.7 and 3.6 versions installed, and apparently all required paths added to the environment variables, pip still isn't recognised.在 Windows 10 上,安装了 Python 2.7 和 3.6 版本,并且显然所有必需的路径都添加到环境变量中,仍然无法识别 pip。

(Btw, when I run the python command, it shows I'm using 3.6) (顺便说一句,当我运行 python 命令时,它显示我正在使用 3.6)

My scripts folders include pip.exe, pip3.exe, pip3.6.exe.我的脚本文件夹包括 pip.exe、pip3.exe、pip3.6.exe。

And my environmental variables look something like this:我的环境变量看起来像这样:

PATH=...;%PYTHON3%;%PYTHON2%;...

Where:
PYTHON2=C:\Python27;C:\Python27\Scripts;C:\Python27\Lib;C:\Python27\DLLs
PYTHON3=C:\Python36;C:\Python36\Scripts;C:\Python36\lib\site-packages;C:\Python36\Lib;C:\Python36\DLLs;C:\Users\Owner\AppData\Local\Programs\Python\Python36;C:\Users\Owner\AppData\Local\Programs\Python\Python36\Scripts

I've tried various permutations of the following:我已经尝试了以下各种排列:

pip
pip3
python3 pip
python3 pip3
py pip
py pip3

But each time I get an error message similar to the following:但是每次我收到类似于以下内容的错误消息时:

Traceback (most recent call last):
  File "runpy.py", line 193, in _run_module_as_main
  File "runpy.py", line 85, in _run_code
  File "C:\Python36\pip3.exe\__main__.py", line 5, in <module>
ModuleNotFoundError: No module named 'pip'

Any ideas how I can get pip working?任何想法如何让 pip 工作?

You are running this from python .您正在从python运行它。

You need run it from CMD or Powershell您需要从CMDPowershell运行它

Windows logo + R Windows 徽标+ R

type cmd

enter进入

pip install <module>

Here's how I got it working.这是我如何让它工作的。

As per the comments from eryksun, I uninstalled and re-ran the Python36 installation, and made sure to click the box to add the paths.根据 eryksun 的评论,我卸载并重新运行 Python36 安装,并确保单击该框以添加路径。 Thereafter it worked.此后它起作用了。

For background, I believe I missed the tickbox to add the paths before.对于背景,我相信我之前错过了添加路径的复选框。 I did notice there were no pip.exe files in the Scripts folder ('perhaps' that was a result of failing to tick add paths).我确实注意到 Scripts 文件夹中没有 pip.exe 文件(“可能”是因为没有勾选添加路径)。

And when I noticed the missing pip files, I tried a manual installation via the https://bootstrap.pypa.io/get-pip.py script.当我注意到缺少 pip 文件时,我尝试通过https://bootstrap.pypa.io/get-pip.py脚本手动安装。 So that's how I ended up with a bunch of pip.exes, but couldn't get pip to work.所以这就是我最终得到一堆 pip.exes 的方式,但无法让 pip 工作。

Anyway, reinstalling and ticking the add paths box worked.无论如何,重新安装并勾选添加路径框有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM