Virtual Env in Python to run Jupyter Notebooks

Harish Pillai
1 min readJun 29, 2024

--

You can create a virtual environment for your Python projects and install Jupyter Notebook within that environment. Here’s how:

To create a virtual environment in Python, you can use the built-in venv module. The basic steps are:

Install venv if it's not already installed:

harish $ python3 -m pip install virtualenv

Create a virtual environment:

The python path should exported as alias or in the path variable to use python3 aliasing. venv provides virtual environment creation support.

harish $ python3 -m venv myenv

Activate the virtual environment:

If (myenv)is display before your cli username then consider the virtual environment is sourced and activated else follow below cmd to do so.

harish $ source myenv/bin/activate
(myenv) harish $

Install Jupyter Notebook in the virtual environment:

harish $ pip install jupyter

Start Jupyter Notebook:

harish $ jupyter notebook

Deactivate virtualenv

When you’re done, deactivate the virtual environment:

harish $ deactivate

This way, your Jupyter Notebook installation will be isolated within the virtual environment, keeping your system’s Python environment clean.

That’s it! You have successfully installed Jupyter Notebook on your Mac.

Thanks for reading,

Harish Pillai

--

--