在Hombrew升级后,PIP3消失了 [英] pip3 gone after hombrew upgrade

查看:23
本文介绍了在Hombrew升级后,PIP3消失了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用brew upgrade升级了过时的软件包,但是现在我发现我以前拥有的pip3命令(Python3的pip)不见了。我的Python 3.6安装仍然在那里:

cls@clsmba > python3
Python 3.6.5 (default, Mar 30 2018, 06:42:10) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 

>pip指向Python 2.7的pip:

cls@clsmba ~> pip --version
pip 9.0.3 from /usr/local/lib/python2.7/site-packages (python 2.7)

cls@clsmba ~> pip2 --version
pip 9.0.3 from /usr/local/lib/python2.7/site-packages (python 2.7)

pip3.5似乎是旧版Python 3遗留下来的:

cls@clsmba ~> pip3.5
Failed to execute process '/usr/local/bin/pip3.5'. Reason:
The file '/usr/local/bin/pip3.5' specified the interpreter '/usr/local/opt/python3/bin/python3.5', which is not an executable command.

我尝试使用get-pip.py取回命令,但没有成功:

cls@clsmba ~> python3 get-pip.py
Requirement already up-to-date: pip in /usr/local/lib/python3.6/site-packages

我现在可以做些什么才能以干净的方式将命令取回?

使用brew reinstall python重新安装未安装pip。另外,请注意错误消息:

cls@clsmba > brew reinstall python
==> Reinstalling python 
==> Installing dependencies for python: sqlite
==> Installing python dependency: sqlite
==> Downloading https://homebrew.bintray.com/bottles/sqlite-3.23.1.sierra.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/75/75bf05c73a9b51101ea166742eb9baf285eda857fd98ea1d50a3abf0d81bd978?__gda__=exp=1523530592~hmac=ae4fc4056ff461c4fc3ca75983cd0f22c231e084312090e6c484aa59b02d3c1f&response-content-disposition=attachment%3Bfilename%3D%22sqlite-3.23.1.sierra.bottle.tar.gz%22&response-content-type=application%2Fgzip&requestInfo=U2FsdGVkX1-3IGgcJJtJX59zX8HP5dbhO9NFlYr07n9KOgP7AOcaoTM4pAOrLWqfH9MzbvCoUoNWKvWGRelKsrku6Kulv8WBBKAT7jGnTKBaYlEQpp1oEnHgh5nU-WVdBxk
######################################################################## 100.0%
==> Pouring sqlite-3.23.1.sierra.bottle.tar.gz
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local,
because macOS provides an older sqlite3.

If you need to have this software first in your PATH run:
  echo 'export PATH="/usr/local/opt/sqlite/bin:$PATH"' >> ~/.bash_profile

For compilers to find this software you may need to set:
    LDFLAGS:  -L/usr/local/opt/sqlite/lib
    CPPFLAGS: -I/usr/local/opt/sqlite/include
For pkg-config to find this software you may need to set:
    PKG_CONFIG_PATH: /usr/local/opt/sqlite/lib/pkgconfig

==> Summary
🍺  /usr/local/Cellar/sqlite/3.23.1: 11 files, 3MB
==> Installing python
==> Downloading https://homebrew.bintray.com/bottles/python-3.6.5.sierra.bottle.tar.gz
Already downloaded: /Users/cls/Library/Caches/Homebrew/python-3.6.5.sierra.bottle.tar.gz
==> Pouring python-3.6.5.sierra.bottle.tar.gz
==> /usr/local/Cellar/python/3.6.5/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/python/3.6.5/bin --install-lib=/usr/local/lib/python3.6/site-packages --single-version-externally-managed --record=installed.txt
Last 15 lines from /Users/cls/Library/Logs/Homebrew/python/post_install.01.python3:
copying setuptools/script (dev).tmpl -> build/lib/setuptools
copying setuptools/script.tmpl -> build/lib/setuptools
copying setuptools/cli-32.exe -> build/lib/setuptools
copying setuptools/cli-64.exe -> build/lib/setuptools
copying setuptools/cli.exe -> build/lib/setuptools
copying setuptools/gui-32.exe -> build/lib/setuptools
copying setuptools/gui-64.exe -> build/lib/setuptools
copying setuptools/gui.exe -> build/lib/setuptools
copying setuptools/command/launcher manifest.xml -> build/lib/setuptools/command
running install_lib
copying build/lib/easy_install.py -> /usr/local/lib/python3.6/site-packages
copying build/lib/pkg_resources/__init__.py -> /usr/local/lib/python3.6/site-packages/pkg_resources
/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'long_description_content_type'
  warnings.warn(msg)
error: could not delete '/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py': Permission denied
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall python`
==> Caveats
Python has been installed as
  /usr/local/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
  /usr/local/opt/python/libexec/bin

If you need Homebrew's Python 2.7 run
  brew install python@2

Pip, setuptools, and wheel have been installed. To update them run
  pip3 install --upgrade pip setuptools wheel

You can install Python packages with
  pip3 install <package>
They will install into the site-package directory
  /usr/local/lib/python3.6/site-packages

See: https://docs.brew.sh/Homebrew-and-Python
==> Summary

根据@Mark Setchell的答案添加路径前缀似乎不会改变事情:

  bash-3.2$ echo $PATH
    /usr/local/opt/python/bin:/usr/local/sbin:/usr/local/Cellar/ruby/1.9.3-p194/bin:/usr/local/share/python3:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/Applications/Server.app/Contents/ServerRoot/usr/bin:/Applications/Server.app/Contents/ServerRoot/usr/sbin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Library/TeX/texbin
    bash-3.2$ python
    Python 2.7.10 (default, Feb  7 2017, 00:08:15) 
    [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> ^D
    bas

h-3.2$ python3
Python 3.6.5 (default, Mar 30 2018, 06:42:10) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 
bash-3.2$ pip3
bash: pip3: command not found
bash-3.2$ pip --version
pip 9.0.3 from /usr/local/lib/python2.7/site-packages (python 2.7)

推荐答案

您需要确定您希望它如何工作,然后自制软件才能满足您的需求。如果您运行以下命令,则该信息可用:

brew info python

Python已安装为/usr/local/bin/python3

指向的未版本化符号链接pythonpython-configpippython3python3-configpip3等 安装到/usr/local/opt/python/libexec/bin

如果您需要Homebrew的Python 2.7运行BREW,请安装python@2

已安装pip、setuptools和车轮。要更新它们,请运行
PIP3安装--升级pip setuptools轮

您可以使用PIP3安装Python软件包 将安装到站点软件包目录
/usr/local/lib/python3.6/site-Packages


所以:

  • 如果要使用版本化命令,即python3pip3idle3,请将/usr/local/opt/python/bin放在路径的开头:

    export PATH=/usr/local/opt/python/bin:$PATH

  • 如果要使用非版本化命令表示Python3及其工具,即pythonpipidle,请将/usr/local/opt/python/libexec/bin放在路径的开头:

    export PATH=/usr/local/opt/python/libexec/bin:$PATH

    /li>
  • 如果您想使用Apple提供的(旧的)Python v2.7作为MacOS的一部分,请将/usr/bin放在路径的开头,并使用命令python

    export PATH=/usr/bin:$PATH

这篇关于在Hombrew升级后,PIP3消失了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆