Embedding and Importing Problems

alantangcs member37767 at dbforums.com
Tue Sep 2 11:21:44 EDT 2003


Hi All,



Currently, I am embedding Python in a C++ program. This is what it does:



1) Initializes the interpreter (Py_Initialize)

2) Run some simple code in a string which adds the directory "Script" to
   "sys.path"

3) Import the module contained in "init.py"



Now I place a file called "test1.py" in the "Script" directory. In
"init.py" (which is in the same directory as the C++ program), I place
the line "import test1".



When I run the program, all seems fine until I reach Py_Finalize. The
program just pops up an "Unhandled exception in ..... (python23.dll)
.... Access Violation".



Amazingly, if I replace the import line with "from test1 import *",
everything works perfectly as well, and I don't get the unhandled
exception problem. Does anyone have any ideas why "import" doesn't work?



Thanks!



Alan


--
Posted via http://dbforums.com




More information about the Python-list mailing list