简体   繁体   中英

How to set up the environment of a Python child process in Windows

I have to launch a Python process from a C++ executable using the CreateProcess Windwos AP I. When I independently run the Python process, the relative paths for importing the libraries work well but when I run the same Python process from a C++ executable, the relative paths for importing the libraries do not work because they will be taking the path relative to the directory in which the C++ executable is kept and not in the directory where the Python file is. So is there a way to set up the environment of a Python process when launching it through the CreateProcess Windows API

This issue has been resolved in the comments by Michael. Reproducing the comment below Set the lpCurrentDirectory parameter accordingly. It will be used to resolve relative paths (if a program doesn't set the current working directory explicitly later) –

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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