如何使自制的python和pyenv一起生活? [英] How can I make homebrew's python and pyenv live together?

查看:69
本文介绍了如何使自制的python和pyenv一起生活?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从2.7.9切换到python 3.4.3(这很简单)之后,我经常希望在与同事共享之前先用python 2.7.9测试我的一些脚本.我正在使用OSX优胜美地平台,所有内容均由自制软件编译而成.

After switching to python 3.4.3 from 2.7.9 (which was quite simple), I often wish to test some of my scripts with python 2.7.9 before sharing them with colleagues. I am using a OSX yosemite platform with everything compiled from homebrew.

情况非常丑陋(在每个步骤中分别设置PATH es和PYTHONPATH)-直到我发现 pyenv 做到这一点非常容易,并且可以使用自制软件轻松安装.到目前为止,一切都很好.

The situation was quite ugly (setting PATHes and PYTHONPATH at each step) - until I discovered pyenv which does this very easily and is easily installed using homebrew. So far, so good.

但是,现在我正在使用此版本的python,它不一定与自制软件兼容.而且,我发现我可以切换回系统的python,更一般地说pyenv可以访问它:

However, now that I am using this version of python, it does not necessarily play well with that of homebrew. Moreover, I found that I could switch back to the system's python, and more generally that pyenv could access that:

$ pyenv versions
  system
  2.7.9
* 3.4.3 (set by /usr/local/var/pyenv/version)

但是如何为自制软件编译的python条目添加条目?

but how could I also add entries for the pythons compiled by homebrew?

推荐答案

您可以在主目录中安装pyenv(如pyenv的安装指南所述),然后在~/.pyenv/versions$(brew --cellar)/python处创建符号链接:

You can install pyenv in your home directory (as described in pyenv's installation guide), and then create a symlink at ~/.pyenv/versions to $(brew --cellar)/python:

ln -s $(brew --cellar python)/* ~/.pyenv/versions/

如今Homebrew的工作方式将同时适用于2.x和3.x.

The way Homebrew works nowadays, this will pick up both 2.x and 3.x.

这篇关于如何使自制的python和pyenv一起生活?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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