Issue
I used to work with python installed under anaconda3
in my Ubuntu. But for some reason, I needed to also create a pyenv
and generalize it for all users. To run python scripts, I learned that unlike anaconda3
, I have to build pyenv
with all the needed python packages as I was receiving errors saying that modules are not defined. For this reason, after installing pyenv
, I installed required modules using pip install <package_name>
in (general) pyenv
shell. And now I am able to run the scripts. Is there a way to switch back and forth between anaconda3
system python and pyenv
python?
(just from the prompt (general) username@username-Rev-1-0:~$, I know that I am in pyenv
right now.)
Here is the relevant portion of .bashrc
file:
# added by Anaconda3 4.3.0 installer
export PATH="/home/username/anaconda3/bin:$PATH"
# Load pyenv automatically by adding
# the following to ~/.bash_profile:
export PATH="/home/username/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
Solution
Try adding this to your .bashrc.
export ANACONDA_HOME="/home/username/anaconda3"
alias my_anaconda="unset PYENV_HOME && export PATH=$ANACONDA_HOME/bin:$PATH"
# Load pyenv automatically by adding
# the following to ~/.bash_profile:
export PYENV_HOME="/home/username/.pyenv/"
alias my_pyenv='unset ANACONDA_HOME && export PATH=$PYENV_HOME/bin:$PATH && eval "$(pyenv init -)" && eval "$(pyenv virtualenv-init -)"'
On shell, try:
$ my_anaconda
$ my_pyenv
Answered By - Sharad Answer Checked By - Marie Seifert (WPSolving Admin)