【问题标题】:Pip problems on Windows 10.0.105 ProWindows 10.0.105 Pro 上的 Pip 问题
【发布时间】:2026-02-17 16:00:01
【问题描述】:

Pip 应该与 Python 3.5 捆绑在一起,但它显然不在我的路径中,而且我没有看到它的二进制文件。

我尝试了这个解决方法:

C:\Python35>py -m pip install requests
You are using pip version 7.0.1, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting requests
  Downloading requests-2.9.1-py2.py3-none-any.whl (501kB)
    100% |################################| 503kB 561kB/s
Installing collected packages: requests
Successfully installed requests-2.9.1

看起来成功了,但显然还是有问题:

C:\Python35>pip3 install --upgrade pip
'pip3' is not recognized as an internal or external command,
operable program or batch file.

C:\Python35>pip install --upgrade pip
'pip' is not recognized as an internal or external command,
operable program or batch file.

C:\Python35>pip install --upgrade pip
'pip' is not recognized as an internal or external command,
operable program or batch file.

C:\Python35>ls
curl.exe  LICENSE.txt   python3.dll     pythonw.exe    tcl
DLLs      NEWS.txt      python3_d.dll   pythonw.pdb    Tools
Doc       python.exe    python35.dll    pythonw_d.exe  vcruntime140.dll
include   python.pdb    python35.pdb    pythonw_d.pdb
Lib       python_d.exe  python35_d.dll  README.txt
libs      python_d.pdb  python35_d.pdb  Scripts

C:\Python35>cd lib

C:\Python35\Lib>ls
__future__.py        dis.py              opcode.py       socketserver.py
__phello__.foo.py    distutils           operator.py     sqlite3
__pycache__          doctest.py          optparse.py     sre_compile.py
_bootlocale.py       dummy_threading.py  os.py           sre_constants.py
_collections_abc.py  email               pathlib.py      sre_parse.py
_compat_pickle.py    encodings           pdb.py          ssl.py
_compression.py      ensurepip           pickle.py       stat.py
_dummy_thread.py     enum.py             pickletools.py  statistics.py
_markupbase.py       filecmp.py          pipes.py        string.py
_osx_support.py      fileinput.py        pkgutil.py      stringprep.py
_pydecimal.py        fnmatch.py          plat-aix4       struct.py
_pyio.py             formatter.py        plat-darwin     subprocess.py
_sitebuiltins.py     fractions.py        plat-freebsd4   sunau.py
_strptime.py         ftplib.py           plat-freebsd5   symbol.py
_threading_local.py  functools.py        plat-freebsd6   symtable.py
_weakrefset.py       genericpath.py      plat-freebsd7   sysconfig.py
abc.py               getopt.py           plat-freebsd8   tabnanny.py
aifc.py              getpass.py          plat-generic    tarfile.py
antigravity.py       gettext.py          plat-linux      telnetlib.py
argparse.py          glob.py             plat-netbsd1    tempfile.py
ast.py               gzip.py             plat-next3      test
asynchat.py          hashlib.py          plat-sunos5     textwrap.py
asyncio              heapq.py            plat-unixware7  this.py
asyncore.py          hmac.py             platform.py     threading.py
base64.py            html                plistlib.py     timeit.py
bdb.py               http                poplib.py       tkinter
binhex.py            idlelib             posixpath.py    token.py
bisect.py            imaplib.py          pprint.py       tokenize.py
bz2.py               imghdr.py           profile.py      trace.py
calendar.py          imp.py              pstats.py       traceback.py
cgi.py               importlib           pty.py          tracemalloc.py
cgitb.py             inspect.py          py_compile.py   tty.py
chunk.py             io.py               pyclbr.py       turtle.py
cmd.py               ipaddress.py        pydoc.py        turtledemo
code.py              json                pydoc_data      types.py
codecs.py            keyword.py          queue.py        typing.py
codeop.py            lib2to3             quopri.py       unittest
collections          linecache.py        random.py       urllib
colorsys.py          locale.py           re.py           uu.py
compileall.py        logging             reprlib.py      uuid.py
concurrent           lzma.py             rlcompleter.py  venv
configparser.py      macpath.py          runpy.py        warnings.py
contextlib.py        macurl2path.py      sched.py        wave.py
copy.py              mailbox.py          selectors.py    weakref.py
copyreg.py           mailcap.py          shelve.py       webbrowser.py
cProfile.py          mimetypes.py        shlex.py        wsgiref
crypt.py             modulefinder.py     shutil.py       xdrlib.py
csv.py               msilib              signal.py       xml
ctypes               multiprocessing     site-packages   xmlrpc
curses               netrc.py            site.py         zipapp.py
datetime.py          nntplib.py          smtpd.py        zipfile.py
dbm                  ntpath.py           smtplib.py
decimal.py           nturl2path.py       sndhdr.py
difflib.py           numbers.py          socket.py

C:\Python35\Lib>ls *pip*
pipes.py

ensurepip:
__init__.py  __main__.py  __pycache__  _bundled  _uninstall.py

C:\Python35\Lib>cd ..

C:\Python35>ls
curl.exe  LICENSE.txt   python3.dll     pythonw.exe    tcl
DLLs      NEWS.txt      python3_d.dll   pythonw.pdb    Tools
Doc       python.exe    python35.dll    pythonw_d.exe  vcruntime140.dll
include   python.pdb    python35.pdb    pythonw_d.pdb
Lib       python_d.exe  python35_d.dll  README.txt
libs      python_d.pdb  python35_d.pdb  Scripts

C:\Python35>cd libs

C:\Python35\libs>ls
_tkinter.lib   python3.lib    python35.lib
libpython35.a  python3_d.lib  python35_d.lib

C:\Python35\libs>cd ..

C:\Python35>ls
curl.exe  LICENSE.txt   python3.dll     pythonw.exe    tcl
DLLs      NEWS.txt      python3_d.dll   pythonw.pdb    Tools
Doc       python.exe    python35.dll    pythonw_d.exe  vcruntime140.dll
include   python.pdb    python35.pdb    pythonw_d.pdb
Lib       python_d.exe  python35_d.dll  README.txt
libs      python_d.pdb  python35_d.pdb  Scripts

 Directory of C:\Python35

12/11/2015  05:06 PM    <DIR>          .
12/11/2015  05:06 PM    <DIR>          ..
12/11/2015  05:06 PM         2,422,784 curl.exe
12/11/2015  04:59 PM    <DIR>          DLLs
12/11/2015  04:59 PM    <DIR>          Doc
12/11/2015  04:58 PM    <DIR>          include
12/11/2015  04:59 PM    <DIR>          Lib
12/11/2015  04:59 PM    <DIR>          libs
12/07/2015  08:03 PM            30,338 LICENSE.txt
12/06/2015  06:32 AM           310,468 NEWS.txt
12/06/2015  01:55 AM            41,240 python.exe
12/06/2015  01:55 AM           405,504 python.pdb
12/06/2015  01:55 AM            51,992 python3.dll
12/06/2015  01:55 AM         3,926,296 python35.dll
12/06/2015  01:55 AM         9,383,936 python35.pdb
12/06/2015  01:52 AM         6,833,664 python35_d.dll
12/06/2015  01:52 AM         7,278,592 python35_d.pdb
12/06/2015  01:52 AM            61,440 python3_d.dll
12/06/2015  01:55 AM            41,240 pythonw.exe
12/06/2015  01:55 AM           405,504 pythonw.pdb
12/06/2015  01:52 AM            64,000 pythonw_d.exe
12/06/2015  01:52 AM           364,544 pythonw_d.pdb
12/06/2015  01:52 AM            64,000 python_d.exe
12/06/2015  01:52 AM           364,544 python_d.pdb
11/22/2015  10:58 PM             8,269 README.txt
12/11/2015  07:39 PM    <DIR>          Scripts
12/11/2015  04:59 PM    <DIR>          tcl
12/11/2015  04:59 PM    <DIR>          Tools
06/25/2015  11:15 PM            88,752 vcruntime140.dll
              19 File(s)     32,147,107 bytes
              10 Dir(s)  63,904,280,576 bytes free

C:\Python35>

【问题讨论】:

  • pip 必须在 python 安装根目录下一个名为 scripts 的目录中,将该路径导入您的环境
  • 上次我在 Windows 上检查了 pip install --upgrade pip 失败,即使您将“脚本”目录添加到 PATH。可以解决替换正在运行的可执行文件的问题,但使用py -3 -m pip install --upgrade pip 很简单。

标签: python windows python-3.x pip


【解决方案1】:

您需要将Scripts 目录导入到您的路径中:

cmd

> setx Path "%Path%;C:\Python35\Scripts"

powershell

$env:Path = $env:Path + ";C:\Python35\Scripts"

【讨论】:

  • setx.exe 修改注册表并广播一个窗口消息,告诉资源管理器从注册表重新加载其环境,但它对当前的 cmd shell 没有影响。为此使用set "PATH=%PATH%;C:\Python35\Scripts"
  • @eryksun 谢谢,我原来的答案是set,但编辑后改为永久setx
  • 不敢相信我错过了!非常感谢
【解决方案2】:

将 pip.exe 路径添加到 $Path 环境变量。 然后以管理员身份运行命令提示符。

【讨论】:

    最近更新 更多