Linux jupyter笔记本电脑可以';t仅在引导时检测conda内核

Linux jupyter笔记本电脑可以';t仅在引导时检测conda内核,linux,amazon-ec2,jupyter-notebook,conda,anaconda3,Linux,Amazon Ec2,Jupyter Notebook,Conda,Anaconda3,我正在尝试在启动时自动启动jupyter服务器。(ec2,亚马逊linux) 我让jupyter服务器正常工作并正确加载了所有conda内核 我试着用靴子跑jupyter。(尝试了rc.local、systemd、crontab和all无法加载conda内核,只能加载基本的python2和python3内核) 我将其追溯到nb_conda_内核无法在启动时调用“conda”,如下所示: Oct 30 01:07:38 ip-172-31-17-102 rc.local: [E 01:07:38.

我正在尝试在启动时自动启动jupyter服务器。(ec2,亚马逊linux)

我让jupyter服务器正常工作并正确加载了所有conda内核

我试着用靴子跑jupyter。(尝试了rc.local、systemd、crontab和all无法加载conda内核,只能加载基本的python2和python3内核)

我将其追溯到nb_conda_内核无法在启动时调用“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).
[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).
最奇怪的是,当我用“sudo ss--tulpn|grep 8888”(为正在侦听端口8888的jupyter笔记本查找pid)和“sudo kill-9{pid}”(杀死进程。检查我是否成功杀死了它)杀死正在运行的服务器时,我通过boot中使用的相同命令重新启动服务器,然后jupyter成功加载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).
[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).
关于这个问题,我在stackoverflow上看到了一个特别的问题。() 但这里的问题是,当我键入“jupyter内核规范列表”时,我只得到python3和python2,即使jupyter已经成功加载了conda内核

python3    /home/ec2-user/anaconda3/share/jupyter/kernels/python3
  python2    /usr/share/jupyter/kernels/python2
此外,我还尝试在jupyter配置文件中更改environmentspecmanager,看看它是否解决了问题,但没有。(同一错误日志,“无法调用conda”)


这里有什么问题?

conda
在执行rc.local时尚未配置。这通常通过
.bashrc
文件完成。但您可以尝试将其添加到
rc.local
脚本中(在启动jupyter之前):


这应该设置在执行rc.local时尚未配置conda

conda
的使用。这通常通过
.bashrc
文件完成。但您可以尝试将其添加到
rc.local
脚本中(在启动jupyter之前):


这将设置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

但在执行rc.local时没有配置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
但在执行rc.local时没有配置conda是正确的。谢谢你把我推向正确的方向,所以我投票接受你的答案