Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在脚本中启动新进程运行python #74

Open
arthurchen1906 opened this issue Mar 19, 2024 · 0 comments
Open

在脚本中启动新进程运行python #74

arthurchen1906 opened this issue Mar 19, 2024 · 0 comments

Comments

@arthurchen1906
Copy link

PyStand.int 做如下修改

import os
import sys
import subprocess

print(123)

subprocess.run('python --version')
os.system('python --version')
os.system('python -m site')

print(sys.path)

PyStand.exe 重新编译了,而且启动了console模式,上面的运行结果只有123sys.path被打印了,中间的没有,但是我用runtime里面的python运行上面的脚本都是可以打印的

我在两台电脑上做了测试,一台是本地已经安装了Python,环境变量中有python路径的。另一台是虚拟机,没有安装过python。

在已经安装了python的电脑上 python -m site 返回的sys.path结果中是包含环境变量中的python的;没有安装python的电脑上,没有返回结果,甚至os.system('python xx.py') 也没有运行结果

正常逻辑来说,在一个python的运行时中启动另一个python进程,如果没有指定路径,那么则应该还是使用原来python的环境

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant