I have both pyenv+virtualenv and Anaconda installed in my system, to manage virtual enviroments.
My .zshrc file looks like this:
# Load pyenv automatically:
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
# added by Anaconda3 4.2.0 installer
export PATH="$HOME/anaconda3/bin:$PATH"
In a given folder I set up a local pyenv virtual environment with
$ pyenv local test-env
Listing the pyenv virtual-envs within that folder results in:
$ pyenv versions
system
2.7.12
2.7.12/envs/test-env
* test-env (set by /home/<path>/.python-version)
But when I load python instead of opening a session with Python v2.7.12 (as one would expect since the pyenv virtual environment is loaded), I get:
$ python
Python 3.5.2 |Anaconda custom (64-bit)| (default, Jul 2 2016, 17:53:06)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
So obviously the Anaconda platform is getting in between my pyenv virtual environment. Listing the conda environments shows:
$ conda-env list
# conda environments:
#
root * /home/<user>/anaconda3
If I comment out the export PATH="$HOME/anaconda3/bin:$PATH" line, pyenv works as expected.
Is there any way to maintain both these managers without conflicting with each other?
The answer was apparently buried in point 3 of the pyenv instructions Basic GitHub Checkout:
Please make sure
eval "$(pyenv init -)"is placed toward the end of the shell configuration file since it manipulatesPATHduring the initialization
So the solution was to move that line to the end of the .zshrc file, like so:
# added by Anaconda3 4.2.0 installer
export PATH="$HOME/anaconda3/bin:$PATH"
# Load pyenv automatically:
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With