Skip to content

Instantly share code, notes, and snippets.

@kleysonr
Last active February 2, 2021 18:25
Show Gist options
  • Save kleysonr/4066260718142d9615f0161c48f53578 to your computer and use it in GitHub Desktop.
Save kleysonr/4066260718142d9615f0161c48f53578 to your computer and use it in GitHub Desktop.
Enable jupyter notebook within a specific virtualenvwrapper
  • Install virtualenvwrapper
$pip install virtualenvwrapper
  • Create a new virtualenv
$mkvirtualenv -p python3 py3env 
  • Activate the virtualenv
$workon py3env
(py3env)$ 
  • Then install jupyter within the active virtualenv
(py3env)$ pip install jupyter
  • Jupyter comes with ipykernel, but somehow you manage to get an error due to ipykernel, then for reference ipykernel package can be installed using:
(py3env)$ pip install ipykernel
  • Set up the kernel
(py3env)$ python -m ipykernel install --user --name py3env --display-name "Python3 (py3env)"

A new kernel defintion will be created under /home/user/.local/share/jupyter/kernels/py3env/kernel.json
  • Start jupyter notebook (not needed activate the venv this step)
(py3env)$ jupyter notebook

   or

$jupyter notebook

In the jupyter notebook dropdown menu: Kernel >> Change Kernel >> <list of kernels> you should see Python3 (py3env) kernel


fonte: https://stackoverflow.com/questions/33496350/execute-python-script-within-jupyter-notebook-using-a-specific-virtualenv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment