【问题标题】:How to run jupyterhub using sudo. Error: commad not found如何使用 sudo 运行 jupyterhub。错误:找不到命令
【发布时间】:2018-10-11 08:16:22
【问题描述】:

我想在我的服务器上运行Jupyterhub。我从the instruction 安装了Jupyterhub。我从我的计算机和在 Ubuntu 16.04 上运行的服务器上都尝试了它。当我在没有 sudo 的情况下启动 Jupyterhub 时,我的计算机上一切正常,我可以使用我的用户登录并启动 jupyter 服务器。但是当我登录后从服务器运行 jupyterhub 时,我得到错误 500:内部服务器错误,这似乎是因为权限错误

PermissionError: [Errno 13] Permission denied

然后我尝试使用 sudo 运行 jupyterhub:sudo jupyterhub -f jc.py 其中jc.py 是我的配置文件。我看到了这个错误:

sudo: jupyterhub: command not found

第一步,我不知道为什么 sudo 不能识别 jupyterhub 命令, 正如指南所说,我使用 conda 安装 jupyterhub。

为了解决这个问题,我从路径中运行 jupyterhub:

sudo anaconda3/bin/jupyterhub -f jc.py 这次我得到了这个错误:

FileNotFoundError: [Errno 2] No such file or directory: 'configurable-http-proxy'

我确信我在运行conda install -c conda-forge jupyterhub # installs jupyterhub and proxy 时安装了'configurable-http-proxy'

为什么sudo 无法识别jupyterhub? 我该如何解决PermissionError

【问题讨论】:

    标签: python ubuntu sudo jupyterhub


    【解决方案1】:

    请指定 conda 安装可配置 http-proxy 的路径。 使用命令从 shell 查找路径
    sudo which configurable-http-proxy

    确保将此路径添加到 root 用户的 PATH 变量中。 检查使用
    sudo echo $PATH

    如果没有,请将其添加到 PATH 并重试。

    【讨论】:

    • 我认为您的方法是正确的,但是当我想将 Conda 添加到 $PATH 时,我得到 sudo: export: command not found。我该怎么做?
    • 尝试在 jupyterhub_config.py(在你的情况下为 jc.py)文件中添加 c.ConfigurableHTTPProxy.command = '/anaconda3/bin/configurable-http-proxy' 。假设configurable-http-proxy的路径是/anaconda3/bin/configurable-http-proxy
    【解决方案2】:

    传递参数--allow-root

    希望有帮助

    【讨论】:

    • 我认为这在我使用 jupyter notebook 时很有帮助,但我使用的是 jupyterhub。
    【解决方案3】:

    试试这个:创建一个服务,并给它[service]标签的root权限。

    也许我这里的 github 会对你有所帮助:

    Github/Jupyter

    [jupyterhub.service] --> /etc/systemd/system/jupyterhub.service(用户=root)

    [Unit]
    Description=Jupyterhub Service
    
    [Service]
    Environment="PATH=/opt/anaconda3/envs/<jupyterbase>/bin:/opt/anaconda3/bin:/opt/anaconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
    ExecStart=/opt/anaconda3/envs/<jupyterbase>/bin/jupyterhub
    WorkingDirectory=/opt/<user>-jupyterhub
    Restart=on-failure
    User=root
    
    [Install]
    WantedBy=multi-user.target
    

    然后:

    $ sudo systemctl start jupyterhub.service
    

    【讨论】:

      猜你喜欢
      • 2021-06-10
      • 2022-01-04
      • 2018-01-24
      • 1970-01-01
      • 2014-08-15
      • 2014-12-20
      • 2012-10-11
      • 2023-04-05
      相关资源
      最近更新 更多