Reputation: 10548
Is there a way to use pipenv with Jupyter notebook?
Or more specifically, with an atom nteract/hydrogen python 3 kernel?
Upvotes: 103
Views: 58778
Reputation: 51
My answer is based on previous answers, but I found one more step was necessary (pipenv install notebook). So in total:
Step 1. On terminal, first install both jupyter and (jupyter) notebook. In my experience, the latter had to be explicitly installed:
pipenv install jupyter notebook
Step 2. Install the Pipenv kernelspec for jupyter (modified from u-phoria's comment).
pipenv run python -m ipykernel install --user --name=`basename $VIRTUAL_ENV`
Now the following should work:
pipenv run jupyter notebook
Note: If in the Pipenv shell for the virtual environment, pipenv run can be removed from the above. If Pipenv is being forced to ignore virtual environments, the run commands should be run in the shell for the environment
For the original question of using Atom, it can then be run by this pipenv:
pipenv run atom
Upvotes: 4
Reputation: 846
Install and start jupyter inside pipenv:
pipenv install jupyter
pipenv run jupyter notebook
Any other packages that are installed via pipenv (e.g. pipenv install numpy
) will also be available to your jupyter notebook session.
Upvotes: 51
Reputation: 2536
Just tried the following with success.
In your project folder:
pipenv install ipykernel
pipenv shell
This will bring up a terminal in your virtualenv like this:
(my-virtualenv-name) bash-4.4$
In that shell do:
python -m ipykernel install --user --name=my-virtualenv-name
Launch jupyter notebook:
jupyter notebook
In your notebook, Kernel -> Change Kernel. Your kernel should now be an option.
Source: IPythonNotebookVirtualenvs
Upvotes: 204
Reputation: 10548
Luis' answer works perfectly for jupyter notebooks.
But for hydrogen/atom specifically the recipe is:
pipenv install ipykernel
pipenv shell
launch atom from within the pipenv shell
> atom
Should be good to go!
Upvotes: 5