Why do I get the error “pyenv: jupyter: command not found, the jupyter command exists in these Python versions”?
If you use pyenv to manage your different Python versions, you might have come across an error message like this one:
pyenv: jupyter: command not found
The `jupyter’ command exists in these Python versions:
3.9.7
Note: See ‘pyenv help global’ for tips on allowing both
python2 and python3 to be found.
pyenv works hard to keep different versions of Python separate. One of the jobs it takes along with that is separating the libraries each version of Python has installed (such as requests, pandas, and yes – Jupyter!).
Typical Python installations don’t separate things so cleanly, and since Jupyter is more than just a normal library – it gets a whole jupyter
command, you know – you commonly end in situations like Python and Jupyter getting disconnected from each other.
When you see this jupyter: command not found
error, it’s pyenv doing its best to keep you from using a Jupyter attached to a different Python than the one you’re using on the command line. In the example above, the user might be using Python 3.10.0 after having previously installed Jupyter with Python 3.9.7.
Alternative explanation: A new Python came out! You got excited! You switched to it! This makes you abandon your old Jupyter installation, no big deal!
There are two ways to fix this:
- Install Jupyter for your fancy new Python with
pip install jupyter
, then continue to use it as normal - Go back to your previous Python version, and stop playing with the new one. In this case,
pyenv global 3.9.7 && pyenv shell 3.9.7
would set the new default Python to be 3.9.7 and switch back to it.
If you’re trying to upgrade to the new Python, you might as well reinstall Jupyter! You’ll probably have plenty of more libraries to reinstall to get back in the groove of your old Python version, but that’s the price you pay for modernity. If you just were poking around at another version because you were bored (right? that’s what human beings do?) then you might as well switch back.