jupyter notebook 仅在启动时无法检测到 conda 内核
jupyter notebook can't detect conda kernels only on boot
我正在尝试在启动时自动启动 jupyter 服务器。 (ec2, 亚马逊 linux)
我让 jupyter 服务器正常工作并正确加载了所有 conda 内核。
我尝试 运行 jupyter 启动。 (已尝试 rc.local、systemd、crontab 和所有无法加载 conda 内核且仅加载基本 python2 和 python3 内核)
我已经将其追溯到 nb_conda_kernels 无法在启动时调用 'conda',如下所示:
Oct 30 01:07:38 ip-172-31-17-102 rc.local: [E 01:07:38.816 NotebookApp] [nb_conda_kernels] couldn't call conda:
Oct 30 01:07:38 ip-172-31-17-102 rc.local: [Errno 2] No such file or directory: 'conda': 'conda'
Oct 30 01:07:38 ip-172-31-17-102 rc.local: [I 01:07:38.816 NotebookApp] [nb_conda_kernels] enabled, 0 kernels found
Oct 30 01:07:39 ip-172-31-17-102 rc.local: [I 01:07:39.645 NotebookApp] Loading IPython parallel extension
Oct 30 01:07:39 ip-172-31-17-102 rc.local: [I 01:07:39.701 NotebookApp] JupyterLab extension loaded from /home/ec2-user/anaconda3/lib/python3.7/site-packages/jupyterlab
Oct 30 01:07:39 ip-172-31-17-102 rc.local: [I 01:07:39.702 NotebookApp] JupyterLab application directory is /home/ec2-user/anaconda3/share/jupyter/lab
Oct 30 01:07:40 ip-172-31-17-102 rc.local: [I 01:07:40.061 NotebookApp] [nb_conda] enabled
Oct 30 01:07:40 ip-172-31-17-102 rc.local: [I 01:07:40.061 NotebookApp] Serving notebooks from local directory: /home/ec2-user/browse
Oct 30 01:07:40 ip-172-31-17-102 rc.local: [I 01:07:40.061 NotebookApp] The Jupyter Notebook is running at:
Oct 30 01:07:40 ip-172-31-17-102 rc.local: [I 01:07:40.061 NotebookApp] http://172.31.17.102:8888/
Oct 30 01:07:40 ip-172-31-17-102 rc.local: [I 01:07:40.061 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
最奇怪的是,当我用“sudo ss --tulpn | grep 8888”(为正在侦听端口 8888 的 jupyter notebook 查找 pid)和“sudo kill”杀死 运行ning 服务器时-9 {pid}”(杀死进程。检查我是否成功杀死它),然后我通过启动时使用的相同命令重新启动服务器,然后 jupyter 成功加载 conda 内核,如下所示:
[I 01:12:51.369 NotebookApp] [nb_conda_kernels] enabled, 22 kernels found
[I 01:12:51.612 NotebookApp] Loading IPython parallel extension
[I 01:12:51.641 NotebookApp] JupyterLab extension loaded from /home/ec2-user/anaconda3/lib/python3.7/site-packages/jupyterlab
[I 01:12:51.641 NotebookApp] JupyterLab application directory is /home/ec2-user/anaconda3/share/jupyter/lab
[I 01:12:51.791 NotebookApp] [nb_conda] enabled
[I 01:12:51.792 NotebookApp] Serving notebooks from local directory: /home/ec2-user/browse
[I 01:12:51.792 NotebookApp] The Jupyter Notebook is running at:
[I 01:12:51.792 NotebookApp] http://172.31.17.102:8888/
[I 01:12:51.792 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
我在 Whosebug 上看到一个关于此问题的特定问题。 ()
但这里的问题是,当我输入“jupyter kernelspec list”时,即使 jupyter 已经成功加载了 conda 内核,我也只会得到 python3 和 python2。
python3 /home/ec2-user/anaconda3/share/jupyter/kernels/python3
python2 /usr/share/jupyter/kernels/python2
此外,我尝试更改 jupyter 配置文件中的 environmentspecmanager 以查看它是否解决了问题,但没有。 (相同的错误日志,“无法调用 conda”)
这里有什么问题?
执行rc.local时,conda
尚未配置。这通常通过 .bashrc
文件完成。但是你可以尝试将它添加到 rc.local
脚本中(在启动 jupyter 之前):
source /home/ec2-user/anaconda3/etc/profile.d/conda.sh
这里要设置conda的使用
谢谢你,FlyterTeller。我在 rc.local 中使用了下面的代码,而不是您显示的代码。
if [ -f "/home/ec2-user/anaconda3/etc/profile.d/conda.sh" ]; then
. "/home/ec2-user/anaconda3/etc/profile.d/conda.sh"
CONDA_CHANGEPS1=false /home/ec2-user/anaconda3/bin/jupyter notebook --config /home/ec2-user/.jupyter/jupyter_notebook_config.py --allow-root --no-browser
fi
但是你说得对,conda 在执行 rc.local 时没有配置。感谢您将我推向正确的方向,所以我赞成并接受您的回答!
我正在尝试在启动时自动启动 jupyter 服务器。 (ec2, 亚马逊 linux)
我让 jupyter 服务器正常工作并正确加载了所有 conda 内核。
我尝试 运行 jupyter 启动。 (已尝试 rc.local、systemd、crontab 和所有无法加载 conda 内核且仅加载基本 python2 和 python3 内核)
我已经将其追溯到 nb_conda_kernels 无法在启动时调用 'conda',如下所示:
Oct 30 01:07:38 ip-172-31-17-102 rc.local: [E 01:07:38.816 NotebookApp] [nb_conda_kernels] couldn't call conda:
Oct 30 01:07:38 ip-172-31-17-102 rc.local: [Errno 2] No such file or directory: 'conda': 'conda'
Oct 30 01:07:38 ip-172-31-17-102 rc.local: [I 01:07:38.816 NotebookApp] [nb_conda_kernels] enabled, 0 kernels found
Oct 30 01:07:39 ip-172-31-17-102 rc.local: [I 01:07:39.645 NotebookApp] Loading IPython parallel extension
Oct 30 01:07:39 ip-172-31-17-102 rc.local: [I 01:07:39.701 NotebookApp] JupyterLab extension loaded from /home/ec2-user/anaconda3/lib/python3.7/site-packages/jupyterlab
Oct 30 01:07:39 ip-172-31-17-102 rc.local: [I 01:07:39.702 NotebookApp] JupyterLab application directory is /home/ec2-user/anaconda3/share/jupyter/lab
Oct 30 01:07:40 ip-172-31-17-102 rc.local: [I 01:07:40.061 NotebookApp] [nb_conda] enabled
Oct 30 01:07:40 ip-172-31-17-102 rc.local: [I 01:07:40.061 NotebookApp] Serving notebooks from local directory: /home/ec2-user/browse
Oct 30 01:07:40 ip-172-31-17-102 rc.local: [I 01:07:40.061 NotebookApp] The Jupyter Notebook is running at:
Oct 30 01:07:40 ip-172-31-17-102 rc.local: [I 01:07:40.061 NotebookApp] http://172.31.17.102:8888/
Oct 30 01:07:40 ip-172-31-17-102 rc.local: [I 01:07:40.061 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
最奇怪的是,当我用“sudo ss --tulpn | grep 8888”(为正在侦听端口 8888 的 jupyter notebook 查找 pid)和“sudo kill”杀死 运行ning 服务器时-9 {pid}”(杀死进程。检查我是否成功杀死它),然后我通过启动时使用的相同命令重新启动服务器,然后 jupyter 成功加载 conda 内核,如下所示:
[I 01:12:51.369 NotebookApp] [nb_conda_kernels] enabled, 22 kernels found
[I 01:12:51.612 NotebookApp] Loading IPython parallel extension
[I 01:12:51.641 NotebookApp] JupyterLab extension loaded from /home/ec2-user/anaconda3/lib/python3.7/site-packages/jupyterlab
[I 01:12:51.641 NotebookApp] JupyterLab application directory is /home/ec2-user/anaconda3/share/jupyter/lab
[I 01:12:51.791 NotebookApp] [nb_conda] enabled
[I 01:12:51.792 NotebookApp] Serving notebooks from local directory: /home/ec2-user/browse
[I 01:12:51.792 NotebookApp] The Jupyter Notebook is running at:
[I 01:12:51.792 NotebookApp] http://172.31.17.102:8888/
[I 01:12:51.792 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
我在 Whosebug 上看到一个关于此问题的特定问题。 (
python3 /home/ec2-user/anaconda3/share/jupyter/kernels/python3
python2 /usr/share/jupyter/kernels/python2
此外,我尝试更改 jupyter 配置文件中的 environmentspecmanager 以查看它是否解决了问题,但没有。 (相同的错误日志,“无法调用 conda”)
这里有什么问题?
conda
尚未配置。这通常通过 .bashrc
文件完成。但是你可以尝试将它添加到 rc.local
脚本中(在启动 jupyter 之前):
source /home/ec2-user/anaconda3/etc/profile.d/conda.sh
这里要设置conda的使用
谢谢你,FlyterTeller。我在 rc.local 中使用了下面的代码,而不是您显示的代码。
if [ -f "/home/ec2-user/anaconda3/etc/profile.d/conda.sh" ]; then
. "/home/ec2-user/anaconda3/etc/profile.d/conda.sh"
CONDA_CHANGEPS1=false /home/ec2-user/anaconda3/bin/jupyter notebook --config /home/ec2-user/.jupyter/jupyter_notebook_config.py --allow-root --no-browser
fi
但是你说得对,conda 在执行 rc.local 时没有配置。感谢您将我推向正确的方向,所以我赞成并接受您的回答!