Python 致命错误:无法获取随机数来初始化 Python
环境 Windows 10、VSC 15
使用 CreateProcessA winapi 并传递 lpenvironment 变量来使用脚本运行 python。当 lpenvironment 传递 null 时,它工作正常。如果我设置环境变量 PATH 和 PYTHONPATH = "paths",并传递 LPSTR(env.c_Str()),它会在运行时抛出上述错误。python版本是3.5.6
有什么帮助吗?
更多细节。
由于某种原因,CreateProcessA 中的第 7 个参数失败,如果为 null,则 python.exe 运行成功,否则打印“Fatal Python error: failed to get random number to Initialize Python”。
std::string Base = Configuration::getBasePath();
std::string environPython = Base;
environPython.append("\\Python;");
environPython.append(Base);
environPython.append("\\Python\\Scripts;");
environPython.append(Base);
environPython.append("\\Python\\include;");
environPython.append(Base);
environPython.append("\\Python\\Lib;"); …Run Code Online (Sandbox Code Playgroud)