19

I trying to use virtualenv on jupyter notebook, to use all packages installed in an environment, but inside jupyter they are not recognized.

Already tried:

pip install tornado==4.5.3
pip install ipykernel==4.8.2

What I do is: Initializing the environment on prompt (windows 7): Move to directory of environment: cd C:\Python\Envs\env1\Scripts and use: activate now the promt show (env1), so it's active.

From there, I move to another directory and call jupyter, but when starts, the package installed on envoriment are not callable.

How we can active the environment on jupyter?

2 Answers 2

33

for Mac OS/Linux users:

python -m venv venv
source venv/bin/activate
pip install jupyter
ipython kernel install --user --name=venv
jupyter notebook
Sign up to request clarification or add additional context in comments.

Comments

16

Maybe you should install an ipykernel inside your venv first.

  1. virtualenv .venv

  2. .venv\Scripts\activate.bat to activate the venv.

  3. python -m pip install ipykernel

  4. python -m ipykernel install --user --name .venv to install a new kernel named .venv.

  5. jupyter notebook here and you can select your new kernel.

REFERENCE: Kernels for different environments

5 Comments

I had to use python -m ipykernel instead of ipykernel from the command line.
@rudolfbyker That's fine. Adding a python -m prefix will be safer.
No, I mean ipykernel was not found on the path, even when the venv is activated.
The reference documentation mentioned suggests python -m ipykernel, there are no mentions of ipykernel as a shell command (anymore?).
I found that I had to exit the venv and re-activate it before it would use the local version of jupyter instead of the global one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.