1

I'm using the Python C API, and numerous times now I've tried using PySys_SetPath() to redirect the interpreter to a path where I've stored all of my scripts. Yet, every time I try it, I get the following error:

Unhandled exception at 0x1e028482 in app.exe: 0xC0000005: Access violation reading location 0x00000004.

I use it in the following syntax: PySys_SetPath("/Python/"). Is that incorrect? Why does it keep crashing? Thanks in advance.

4

2 回答 2

0

除非您的 python 目录位于系统根文件夹中,否则路径命名错误。它应该是

PySys_SetPath("Python");

假设 python 文件夹位于当前工作目录中。

于 2014-06-03T15:31:04.277 回答
0

我遇到了同样的问题,但是当我修复了所有\to/.在路径的开头添加了它时,它起作用了,
即。路径应该看起来像那样PySys_SetPath("./Python/")PySys_SetPath("C:/full/path/Python/")

于 2017-05-16T12:46:34.250 回答