Solve the problem that os.system() does not recognize instructions

The problem is as follows:
insert image description here
here I have installed blender.exe, and have set the environment variables, and testing blender -h in cmd can also pass.

but!

insert image description here
As shown in the picture, XXX is not recognized as an internal or external command,
(Note: If you even have garbled characters here, then use technology! Add a line of code to solve it perfectly)

os.system('chcp 65001')

I found a series of methods on the Internet but failed to solve this problem, so I wrote this record.
Let's go to technology and add a line of code to solve it perfectly.

os.environ[‘环境变量名称’] #获取系统环境变量

The reason is that unlike cmd, it cannot automatically load environment variables.

The absolute path of blender can also be written here. If you write the code yourself, you can write os.environ in the code, and use export to set the environment variable outside, double insurance.

True love life, stay away from windows!
It's all technology and hard work, buddy!
after class~

Reference

Link: python os set environment variables

Guess you like

Origin blog.csdn.net/qq_44324007/article/details/127362435