【问题标题】:Why the ‘sudo nohup python a.py &’ command cannot find numpy?为什么‘sudo nohup python a.py &’命令找不到numpy?
【发布时间】:2020-10-01 23:23:03
【问题描述】:

我已经安装了 python 和 numpy,并且可以使用 'python a.py' 命令运行 a.py。 a.py 在这里:

import numpy as np
print(np.__version__)

但是当我使用命令 'sudo nohup python a.py &' 运行 a.py 时,没有名为 numpy 的模块。 详细信息如下图所示。 更重要的是,我的 linux 版本是 ubuntu 18_04 64。 Detail img

【问题讨论】:

  • 您是否在 python 虚拟环境的上下文中安装了 numpy? pythonsudo 环境中是否解析为与普通用户相同的命令?
  • 你能成功运行sudo python a.py吗?

标签: python bash numpy ubuntu


【解决方案1】:

问题是sudoimport 以root 身份正常工作,请检查: PYTHONPATH not working for sudo on GNU/Linux (works for root) 可能会有所帮助。

【讨论】:

    猜你喜欢
    • 2014-04-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-06
    • 1970-01-01
    • 1970-01-01
    • 2012-03-30
    • 2021-09-05
    相关资源
    最近更新 更多