I am trying to configure my IMAC (mavericks) to be able to easily switch to different versions of python. I successfully did this for Ruby projects with rbenv and found pyenv exactly in what I was looking for in this regard. I had a problem creating virtual environments with pyenv.
I tried installing pyenv-virtualenv since I thought this would work well with pyenv, but at the moment it looks broken and it is difficult for me to get a detailed answer. At first, the activate command does not work (it says that the command does not exist, despite the docs), and as soon as I installed the pyenv-virtualenv plugin, pyenv no longer uses the correct version of python. I eventually uninstalled the plugin and pyenv started working again.
Now I would like to use the usual virtalenvwrapper with pyenv, but I continue to encounter errors that I don’t have enough to solve.
To get started, I installed pyenv and virtualenv and virtualenvwrapper according to the documentation. Then I installed python 2.7.6 with pyenv. This works fine, but when I try to configure virtualenvwrapper settings in .bash_profile, I encounter the following error:
-bash: /usr/local/bin/python: No such file or directory
virtualenvwrapper.sh: There was a problem running the initialization hooks.
If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenv has been installed for
VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python and that PATH is
set properly.
If I check the python paths, I get the following:
bin [master] >> which python
/usr/bin/python
bin [master] >> pyenv which python
/Users/insomniac/.pyenv/versions/2.7.6/bin/python
I tried to set VIRTUALENVWRAPPER_PYTHONboth /usr/local/bin/python, and so, /usr/bin/python
but none of these settings work - I keep getting the same error.
I really don't want to use /Users/insomniac/.pyenv/versions/2.7.6/bin/python
it because it seems to be wrong, because the python version is listed and goes against the ability to switch python versions.
These are the related settings in my .bash_profile:
export PYTHONPATH=/Users/insomniac/Repo/tools/python/:$PYTHONPATH
export PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:sbin:$PATH
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Repo
export PIP_VIRTUALENV_BASE=$WORKON_HOME
export PIP_RESPECT_VIRTUALENV=true
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
if [[ -s /usr/local/bin/virtualenvwrapper.sh ]]; then
source /usr/local/bin/virtualenvwrapper.sh
fi
eval "$(pyenv init -)"
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
.bashrc :
syspip(){
PIP_REQUIRE_VIRTUALENV="" pip "$@"
}
export PIP_REQUIRE_VIRTUALENV=true
export PIP_DOWNLOAD_CACHE=$HOME/.pip/cache
, , . pyenv, virtualenv virtualenvwrapper, , pyenv.
, . ( ), . .
.