0

I created a Pyenv virtual env. After activating the env, I download libraries like pandas into it. However, when I open a jupyter notebook from the same environment's terminal, pandas is not found there. It gives a module not found. I believe it's because the Jupiter notebook is using python from somewhere else while my other terminal was using python from somewhere else:

From my terminal, when I check which python, I get this:

/Users/username/.pyenv/shims/python

How can I ensure that my jupypter notebook is using the same env?

P.S I know I can separately install libraries again in the Jupiter notebook but that's not my qs

x89
  • 2,798
  • 5
  • 46
  • 110

1 Answers1

0

I would suggest to click on "Kernel" in the jupyter notebook bar (in the top). Next go to "Change Kernel" then select the venv you created

Edit: ok I tried it myself

after you activate your venv make sure to ..

install jupyter within the venv:

pip install jupyter

then :

ipython kernel install --name "my-venv" --user

(or however you want to name it) -> this will add your virtualenvironment as kernel for jupyter

then run

jupyter-notebook

when inside the notebook click on "New" in top right corner, then choose the name you gave the kernel before ("my-venv") -> et vilà

Aku
  • 660
  • 6
  • 9