安装Homebrew Python并链接 [英] Installing Homebrew Python and linking

查看:195
本文介绍了安装Homebrew Python并链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用Python的Homebrew版本而不是Python的系统版本.我已经全新安装了macOS Sierra(10.12.5).

I need to use the Homebrew version of Python rather than the system version of Python. I have a clean install of macOS Sierra (10.12.5).

我先安装了自制软件,然后使用nano ~/.bash_profile更新了~/.bash_profile. 然后我将其添加到文件中:

I first installed homebrew and then updated ~/.bash_profile using nano ~/.bash_profile. Then I added this into the file:

# Homebrew
export PATH=/usr/local/bin:$PATH

然后,我需要手动获取~/.bash_profile文件,以确保使用source ~/.bash_profile重新加载了更改.

Then, I needed to manually source the ~/.bash_profile file to ensure the changes have been reloaded using source ~/.bash_profile.

我使用brew install python安装了python,并尝试使用brew linkapps python

I installed python using brew install python and tried to link using brew linkapps python

输出是这样的:

Warning: Already linked: /usr/local/Cellar/python/2.7.13_1
To relink: brew unlink python && brew link python
Gautams-Air:~ gautam$ which python
/usr/bin/python
Gautams-Air:~ gautam$ python -V
Python 2.7.10
Gautams-Air:~ gautam$ brew linkapps python
Warning: brew linkapps has been deprecated and will eventually be removed!

Unfortunately brew linkapps cannot behave nicely with e.g. Spotlight using
either aliases or symlinks and Homebrew formulae do not build "proper" .app
bundles that can be relocated. Instead, please consider using brew cask and
migrate formulae using .app's to casks.
Linking: /usr/local/opt/python/IDLE.app
Linking: /usr/local/opt/python/Python Launcher.app
Linked 2 apps to /Applications`

使用which python的输出是: /usr/bin/python

应该是:/usr/local/bin/python

我也尝试使用:brew unlink python && brew link python

也使用python -V会显示Python 2.7.10,尽管Homebrew中的当前版本是Python 2.7.13

Also using python -V it shows Python 2.7.10 although the current version in Homebrew is Python 2.7.13

如何使用Python的Homebrew版本而不是Python的系统版本? -如何链接?

How do I use the Homebrew version of Python instead of the system version of Python? - How do I do the linking?

使用: macOS Sierra(10.12.5)

USING: macOS Sierra (10.12.5)

推荐答案

由于从版本2.7.13_1开始对python2的Homebrew公式进行了最新更改,因此Homebrew不再为python创建到Homebrew版本的符号链接.

Due to a recent change in the Homebrew formula for python2 starting with version 2.7.13_1, Homebrew no longer creates a symlink for python to the Homebrew version.

相反,它仅安装和符号链接python2.您需要采取其他步骤才能使用它,而不是Python的系统版本.

Instead, it only installs and symlinks python2. You will need to take an additional step to use it instead of the system version of Python.

请参阅此软件包信息中的注意事项"部分.下面是一个示例,但请注意,实际导出的PATH已生成,并且在您的计算机上可能有所不同.

See the "Caveats" section in this package's info. Below is an example, but note that the actual PATH to export is generated and may be different on your machine.

$ brew info python2

... snip ...

=> Caveats
This formula installs a python2 executable to /usr/local/bin.
If you wish to have this formula's python executable in your PATH then add
the following to ~/.bash_profile:
  export PATH="<... some path ...>:$PATH"

... snip ...

Homebrew在其

Homebrew talked more about this change in their recent release notes.

这篇关于安装Homebrew Python并链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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