Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
107 views
in Technique[技术] by (71.8m points)

How can I make homebrew's python and pyenv live together?

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.

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.

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)

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

question from:https://stackoverflow.com/questions/30499795/how-can-i-make-homebrews-python-and-pyenv-live-together

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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/

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...