brew安装python - 在OSX上失败
我正在通过 brew
安装 Python,使用的是:
brew install python
但是遇到了以下错误:
Stevens-MacBook-Pro :: ~ ‹master*› » brew install python
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/python-2.7.
Already downloaded: /Library/Caches/Homebrew/python-2.7.8_2.mountain_lion.bottle.tar.gz
==> Pouring python-2.7.8_2.mountain_lion.bottle.tar.gz
==> Caveats
Setuptools and Pip have been installed. To update them
pip install --upgrade setuptools
pip install --upgrade pip
You can install Python packages with
pip install <package>
They will install into the site-package directory
/usr/local/lib/python2.7/site-packages
See: https://github.com/Homebrew/homebrew/wiki/Homebrew-and-Python
.app bundles were installed.
Run `brew linkapps` to symlink these to /Applications.
/usr/bin/install_name_tool: object: /usr/local/Cellar/python/2.7.8_2/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python malformed object (unknown load command 10)
Error: Failed to fix install names
The formula built, but you may encounter issues using it or linking other
formula against it.
==> /usr/local/Cellar/python/2.7.8_2/bin/python -ssetup.py --no-user-cfg instal
using one of the approaches described here:
Please make the appropriate changes for your system and try again.
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall python`
==> Summary
/usr/local/Cellar/python/2.7.8_2: 4626 files, 73M
错误信息显示安装后出现问题,并建议我再试一次安装,使用:
brew postinstall python
但错误依然存在。我还尝试了 brew linkapps
,它成功链接了 Python,但当我在控制台运行 pip
时却出现了这个错误:
Stevens-MacBook-Pro :: ~ ‹master*› » pip
zsh: /usr/local/bin/pip: bad interpreter: @@HOMEBREW_PREFIX@@/opt/python/bin/python2.7: no such file or directory
有没有人知道可能出什么问题了?
1 个回答
1
Pyenv 是一个用来管理 Python 版本的工具,类似于 rbenv,但专门为 Python 设计的。
通过 pyenv,你可以很轻松地安装和切换 Python 版本。
下面是如何通过 pyenv 安装 2.7.8 版本的 Python 的示例:
ubuntu@ubuntu:~$ pyenv install 2.7.8
Downloading Python-2.7.8.tgz...
-> http://yyuu.github.io/pythons/74d70b914da4487aa1d97222b29e9554d042f825f26cb2b93abd20fdda56b557
Installing Python-2.7.8...
Installing setuptools from https://bootstrap.pypa.io/ez_setup.py...
Installing pip from https://bootstrap.pypa.io/get-pip.py...
Installed Python-2.7.8 to /home/ubuntu/.pyenv/versions/2.7.8
如你所见,这个过程非常简单。
命令 pyenv install "version"
可以帮助你轻松安装特定版本的 Python,甚至 pip 和 setuptools 也会自动安装。
我建议你试试 pyenv!!