首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将jupyter脚本添加到路径

如何将jupyter脚本添加到路径
EN

Stack Overflow用户
提问于 2020-06-29 05:28:19
回答 2查看 1.5K关注 0票数 1

我总是在添加路径时苦苦挣扎。

安装jupyter笔记本后,它会发出警告

代码语言:javascript
复制
The scripts jupyter, jupyter-migrate and jupyter-troubleshoot are installed in '/Users/gangzhao/Library/Python/3.7/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  The scripts jupyter-kernel, jupyter-kernelspec and jupyter-run are installed in '/Users/gangzhao/Library/Python/3.7/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  The script jsonschema is installed in '/Users/gangzhao/Library/Python/3.7/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  The script jupyter-trust is installed in '/Users/gangzhao/Library/Python/3.7/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  The script pygmentize is installed in '/Users/gangzhao/Library/Python/3.7/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  The script jupyter-nbconvert is installed in '/Users/gangzhao/Library/Python/3.7/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  The scripts iptest, iptest3, ipython and ipython3 are installed in '/Users/gangzhao/Library/Python/3.7/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  The scripts jupyter-bundlerextension, jupyter-nbextension, jupyter-notebook and jupyter-serverextension are installed in '/Users/gangzhao/Library/Python/3.7/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  The script jupyter-console is installed in '/Users/gangzhao/Library/Python/3.7/bin' which is not on PATH. 
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

我发现了一个关于添加目录到PYTHONPATH的真正的good post

但我还是想不通。

代码语言:javascript
复制
export PYTHONPATH="${PYTHONPATH}:/my/other/path"

我搞不清什么是PYTHONPATH,什么是/my/other/path

EN

回答 2

Stack Overflow用户

发布于 2020-06-29 08:31:17

也许你应该试试在安装Anaconda时使用内置的jupyter笔记本。当我通过Anaconda安装Jupyter时,从来没有遇到过这样的问题。

票数 0
EN

Stack Overflow用户

发布于 2021-10-17 16:00:02

不知道你是否已经修复了这个问题,但我最近在树莓派的零W上构建jupyter时也重现了同样的错误,所以我想我发布了一个解决方案。

我的连接是通过putty的ssh

首先,我通过pip3正常安装了jupyter,并且在垃圾桶上也收到了多个路径错误。已确认这一点,因为运行任何jupyter命令都会返回not found。

我的解决方案是只做一个服务,你可以通过首先找到jupyter二进制文件的位置来实现:which jupyter-lab。这应该返回二进制文件的路径,并且应该非常类似于:/home/pi/.local/bin/jupyter-lab。记录此信息,因为在/etc/systemd/system/中创建文件时需要此信息

创建服务:

代码语言:javascript
复制
sudo nano /etc/systemd/system/jupyter.service

使用以下内容填充文件:

代码语言:javascript
复制
[Unit]
    Description=Jupyter Lab
[Service]
    Type=simple
    PIDFile=/run/jupyter.pid
    ExecStart=/bin/bash -c "/home/pi/.local/bin/jupyter-lab --ip="0.0.0.0" --no-browser --notebook-dir=/home/pi/notebooks"
    User=pi
    Group=pi
    WorkingDirectory=/home/pi/notebooks
    Restart=always
    RestartSec=10
[Install]
    WantedBy=multi-user.target

请注意,ExecStart=是您放置先前找到的二进制文件的路径的位置。这也是配置jupyter-lab的参数的地方,包括IP和notebook directory。需要注意的是,我已经为此设置了我的目录。

接下来,我们可以轻松地运行此服务:

代码语言:javascript
复制
sudo systemctl start jupyter.service

或者停止它:

代码语言:javascript
复制
sudo systemctl stop jupyter.service

我想让服务在每次启动时启动:

代码语言:javascript
复制
sudo systemctl enable jupyter.service
sudo systemctl daemon-reload

检查服务状态:

代码语言:javascript
复制
sudo systemctl status jupyter.service

这将为您提供有关从jupyter运行的ServerApp的有用服务信息。此处还将显示用于连接到您的笔记本的令牌和URL。

希望这对解决任何问题有帮助!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62628411

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档