python subprocess not the def
我正在使用子过程调用Python脚本,但它不起作用,因为它找不到我的PythonPath
。我有一个我的pythonpath
put,它进入了我的文件夹。 假设我的PythonPath
包含以下路径:/home/myproject
。 我的体系结构是这个:/myproject/djangoview/view_x.py
从我的view_x.py
我使用subprocess启动/myproject/scripts/script.py.py
然后启动服务器django上的脚本,我必须单击一个按钮,它应该启动我的script.py
,要清楚它确实可以在本地工作,但是它在preprod中不起作用,这是服务器ubuntu。 我遇到的错误是modulenotfound
,因为在我的脚本中,我调用/utils/utils.py
,
所以我只是不太了解我为什么有错误,我的> pythonpath
是设置并正确的,所有调用/utils/utils.py
的导入都在工作,除非我在preprod Server中使用subprocess。我不能在本地复制它。 有人对这种行为有解释吗?
这是我的电话:
subprocess.run(["nohup python3 /home/myproject/scripts/script.py &"], shell=True)
thanx。
I'm using subprocess to call a python script but it doesn't work because it doesn't find my PYTHONPATH
. I have a my PYTHONPATH
put and it goes inside my folder.
let's say my PYTHONPATH
contains this path: /home/myproject
.
My architecture is this one: /myproject/djangoView/view_x.py
from my view_x.py
I use subprocess to launch a script that is on /myproject/scripts/script.py
Then I start my server django, I have to click on a button and it should launch my script.py
, to be clear it does work in local, but it doesn't work in preprod which is a server ubuntu.
The error I have is ModuleNotFound
because in my script I call /utils/utils.py
So I just don't really understand why I have an error, my PYTHONPATH
is set and correct, all the imports calling /utils/utils.py
are working except when I'm using subprocess in my preprod server. I can't reproduce it in local.
Is someone have an explanation for this behavior ?
Here is my call:
subprocess.run(["nohup python3 /home/myproject/scripts/script.py &"], shell=True)
Thanx.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论