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

后端 未结 4 1513
北海茫月
北海茫月 2020-12-22 22:56

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 usin

4条回答
  •  不知归路
    2020-12-22 23:39

    Well if you want the pyenv pythons and homebrew pythons to live together you need to make the name of the homebrew pythons something other than the version. Otherwise they will clash with the directory names that pyenv uses. For example, if you want to install pyenv python 2.7.11 and homebrew python 2.7.11 you could do something like this.

    for i in `ls $(brew --cellar python)/`; do 
      ln -s $(brew --cellar python)/$i $HOME/.pyenv/versions/$i-brew; 
    done
    
    for i in `ls $(brew --cellar python3)/`; do 
      ln -s $(brew --cellar python)/$i $HOME/.pyenv/versions/$i-brew; 
    done
    

    Essentially this will create a directory in $HOME/.pyenv/versions appended with '-brew' so that it won't clash with the pyenv pythons.

提交回复
热议问题