pyenv command not found - Jupyter notebook

Viewed 10516

I already referred to this related post

I am currently using a jupyter notebook in my server (where I don't have sudo access) which has python 2.7 kernel.

However, I would like to add Python >= 3.5 as the kernel. So, I was using followed the tutorial to install Pyenv.

The installation is successful and I get the below message in my jupyter notebook

WARNING: seems you still have not added 'pyenv' to the load path.

# Load pyenv automatically by adding
# the following to ~/.bashrc:

export PATH="/home/abcd/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)" 

Later, when I try to execute the below command, I get an error as shown below

!pyenv install --list | grep " 3\.[678]" 

Please note that I am using ! symbol as I am executing it from Jupyter notebook cell

/bin/sh: 1: pyenv: not found

How can I avoid this error and make pyenv work and produce the below output

enter image description here

1 Answers

As per the discussion in comments section, it turns out the pyenv path wasn't exported to .bashrc. It can be done by executing the following commands in terminal:

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bashrc

then restart the shell

exec "$SHELL"

Now, you can use pyenv to create virtual environments, then activate the environment and start working without interfering with the system environment.

Related