Reputation: 1161
Background: while running Jupyter Notebook a new import was failing even though the library was installing successfully using pip3. Some of the set up for the code I was running was done in PyCharm which was using a virtual Python 3.8.2 environment. The failing import library is in the virtual environment so why isn't Jupyter seeing it?
I went looking and found that there are multiple versions of Python installed:
I have installed pyenv and virtualenv and tried (unsuccessfully) to sort things out through this and similar articles. But all of this has only left me with questions:
Upvotes: 2
Views: 2323
Reputation: 1161
A few years later and here is how I now handle this situation:
conda create <env name> python=3.10.8
(or whatever version you want)This means that every python project has exactly the python version I specify. My workflow is basically:
requirements.txt
filepip install -r requirements.txt
The last one is important. I've always found my packages (data science) in pip
but not always in conda
, and mixing conda
and pip
packages has always led to tears. This way I keep it all pure.
Note: why miniconda
and not venv
? Because that's what all the devs in our office are using, no other reason.
Upvotes: 0
Reputation: 5196
After trying @Akbar30bill's answer without success I did brew doctor
and restarted my terminal and tried again and it worked. Wasn't linked correctly or something.
Upvotes: 1
Reputation: 362
installing jupyter with pip from pyenv fixed my problem
brew uninstall jupyter
pip install jupyter
and after restarting your console it should be pyenv's jupyter
Upvotes: 2