简体   繁体   English

为什么 python 不读取环境变量并且无法运行 windows 命令行?

[英]Why python doesn't read the environment variable and can't run a windows command line?

I am trying to run the appium server from my python 3.7 code.我正在尝试从我的 python 3.7 代码运行 appium 服务器。 So I use this simple line of code:所以我使用这个简单的代码行:

os.system("start /B start cmd.exe @cmd /k appium")

I see the command windows pop up and give the error "appium' is not recognized as an internal or external command, operable program or batch file".我看到命令 windows 弹出并给出错误“appium'不被识别为内部或外部命令,可运行程序或批处理文件”。

But I checked my environment variable and they are fine.但是我检查了我的环境变量,它们很好。 I can even run appium from command by hand from same folder.我什至可以从同一文件夹中手动从命令运行 appium。 Please check the screenshot as a prove:请检查屏幕截图作为证明:

在此处输入图像描述

So what I am doing wrong?那么我做错了什么? Doesn't anyone can help me please?没有人可以帮助我吗?

After some investigation, this is the command which fix my issue:经过一番调查,这是解决我的问题的命令:

proc = subprocess.Popen('npm install -g appium',shell=True,stdin=None, stdout=True, stderr=None, close_fds=True)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM