Reputation: 713
I'm making a .dll for an .exe program and embedding python in it. It worked fine with this simple .py program
from time import *
##import OptimRestriction
def test_callsign(b):
...(simple script)
return
What I did was copy the .py program, the Dll and Lib folders into the xxx.exe folder, like is said here.
But as soon as I uncomment the import of OptimRestriction
the debug crashes. First it starts loading symbols when the call to the thread that initializes and deals with Python is called: _ctypes.pyd
,_sockets.pyd
,sst_pyd
,harshlib.pyd
,unicodedata.pyd
,tkinter.pyd
, all modules that the OptimRestriction
does not use.
The error given after the debug crashes is:
Unhandled exception at 0x1E0AA0C5 (python27.dll) in xxx.exe: 0xC0000005: Access violation reading location 0x00000004.
And it breaks on the _callthreadstart
function.
OptimRestriction
is a long program that imports a lot of modules (that are also in the .exe folder). Here's the list of its imports:
from GrafFunc import *
from LogFunc import *
from DinamicaFunc import *
from Dinamica2 import *
from CDR import *
...
import sys
import cProfile"
What it seems to me is that the thread takes too long to start because the debug starts loading those files for a long time, and so it gives an error. Am I correct? And if so, why is it loading those files if OptimRestriction
and its impots don't use them?
Edit:New information. It crashes saying Can't import module
on this line:
pModule = PyImport_Import(pName);
Upvotes: 1
Views: 1327
Reputation: 713
After long hours of reducing the problem to some lines of code, i just found out that the problem was in the lines where some of the modules opened .txt files to read.
I thought that having the .txt files in the same folder of the .py programs was the correct thing to do, but it seems that I needed to copy them to the folder of my c++ plugin (I think that's because while I'm debugging, the system path is changed for my plug-in folder since the writing and reading of pyhton is done to/from there)
Problem solved!
Upvotes: 1