Python 有没有办法在 Jupyter 笔记本中使用 pipenv?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/47295871/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there a way to use pipenv with Jupyter notebook?
提问by emehex
Is there a way to use pipenv with Jupyter notebook?
有没有办法在 Jupyter 笔记本中使用 pipenv?
Or more specifically, with an atom nteract/hydrogen python 3 kernel?
或者更具体地说,使用原子交互/氢 python 3 内核?
回答by Luis Meraz
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:
这将在您的 virtualenv 中打开一个终端,如下所示:
(my-virtualenv-name) bash-4.4$
In that shell do:
在那个壳里做:
python -m ipykernel install --user --name=my-virtualenv-name
Launch jupyter notebook:
启动 jupyter 笔记本:
jupyter notebook
In your notebook, Kernel -> Change Kernel. Your kernel should now be an option.
在您的笔记本中,内核 -> 更改内核。您的内核现在应该是一个选项。
Source: IPythonNotebookVirtualenvs
回答by dahe
Install and start jupyter inside pipenv:
在 pipenv 中安装并启动 jupyter:
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.
通过 pipenv(例如pipenv install numpy
)安装的任何其他软件包也可用于您的 jupyter notebook 会话。
回答by emehex
Luis' answer works perfectly for jupyter notebooks.
Luis 的回答非常适用于 jupyter 笔记本。
But for hydrogen/atom specifically the recipe is:
但是对于氢/原子,具体的配方是:
pipenv install ipykernel
pipenv shell
launch atom from within the pipenv shell
从 pipenv shell 内启动原子
> atom
Should be good to go!
去应该不错!