To get started with virtual environments, simply download virtualenv using pip install virtualenv
Then do the following:
- Navigate to the folder you would like to work from
- Run
virtualenv demo_envwheredemo_envis what you would like to call the environment
- Assuming you are in the folder where the virtualenv was intialized, run
source demo_env/bin/activateto activate the environment
Now all the packages you install using pip will be local to this folder!
- Type
deactivate
In order to make use of a virtual environment that you have created when running a Jupyter notebook:
- Make sure that your virtual environment has been activated
- Run
ipython kernel install --user --name "demo_env", wheredemo_envis the name of the environment you wish to use - In your Jupyter notebook, click Kernel -> Change Kernel and select your environment (in this example,
demo_env), from the list.