如何链接Home BREW Python版本并将其设置为默认版本 [英] How to link home brew python version and set it as default

查看:30
本文介绍了如何链接Home BREW Python版本并将其设置为默认版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚从MacPorts切换到自制软件。在安装了所有必需的XCode版本和其他软件后,我尝试使用自制软件安装python:我认为它安装成功,但是当我安装which python时,它仍然显示2.7.3,我认为这是Mountain Lion附带的版本。

which python
/usr/local/bin/python

python --version
Python 2.7.3

因此我尝试重新安装

brew install python --framework --universal
Warning: python-2.7.5 already installed, it's just not linked

但显示python 2.7.5已安装且未链接,我尝试brew link python

这导致我收到以下消息,所以我不知道我应该做什么:

正在链接/usr/local/Cella/python/2.7.5.警告:无法链接python。正在取消链接.

Error: Could not symlink file: /usr/local/Cellar/python/2.7.5/bin/smtpd2.py
Target /usr/local/bin/smtpd2.py already exists. You may need to delete it.
To force the link and overwrite all other conflicting files, do:
  brew link --overwrite formula_name

To list all files that would be deleted:
  brew link --overwrite --dry-run formula_name

推荐答案

使用brew install python3安装python3之后 我收到错误:

Error: An unexpected error occurred during the `brew link` step
The formula built, but is not symlinked into /usr/local
Permission denied @ dir_s_mkdir - /usr/local/Frameworks
Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks

键入brew link python3后,错误为:

Linking /usr/local/Cellar/python/3.6.4_3... Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks

要解决问题,请执行以下操作:

sudo mkdir -p /usr/local/Frameworks
sudo chown -R $(whoami) /usr/local/*
brew link python3

之后,我可以通过键入python3👍

打开python3

(来自https://github.com/Homebrew/homebrew-core/issues/20985)

这篇关于如何链接Home BREW Python版本并将其设置为默认版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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