Question

My environment is delphi7 and Python2.6.6, python for delphi installed.

But when I run a test app, I got a runtime error.

Microsoft Visual C++ Runtime Library
Runtime Error!
program:E:\programming\delphi\p4dtest\dd\project1.exe

This application has requeste, the Runtime to terminate it in an unusual way.  
Please contact the application's support team for more information.

test.py:

import ctypes
print 'hello'

delphi app main:

procedure TForm1.Button1Click(Sender: TObject);
begin
      PyExeFile('test.py', PE);    
end;

It runs ok if I remove the line "import ctypes", but failed if ctypes is imported.

I googled and found an issue on this: http://code.google.com/p/python4delphi/wiki/P4DPython26.

According to the article, I compile the res file and put the res file and Microsoft.VC90.CRT.manifest even msvcr90.dll in the project folder, add XP_UAC.RES in the project file, but I still got the error. Then I reinstalled the Microsoft Visual C++ 2008 SP1 Redistributable Package, but it seems not the problem. Did anyone use the P4D under python2.6 successfully, please tell me how I can make it.

==================================
Now i have solved the ploblem by myself through reading the issues on the official website of P4D:

1、In the pythonengine property tab

‍keep set  “UseLastKnownVersion” to True

‍keep ‍set   "DLLName"  to  python26

2、on your PythonEngine component and adjust your define:

{$DEFINE PYTHON26}

which you can do in the project options of Delphi 7.  
Just add PYTHON26 to the "conditional defines" dialog box.

By the way, I don't mean to confuse everyone of my question, if it does, I'm sorry for that, so please don't devote others' question arbitrarily if you didn't try by yourself.

Was it helpful?

Solution

Maybe I did't describe my question clearly. Now i have solved the ploblem by myself through reading the issues on the official website of P4D:

1、In the pythonengine property tab

‍keep set  “UseLastKnownVersion” to True

‍keep ‍set   "DLLName"  to  python26

2、On your PythonEngine component and adjust your define:

{$DEFINE PYTHON26}

which you can do in the project options of Delphi 7.  
Just add PYTHON26 to the "conditional defines" dialog box  

OTHER TIPS

I tried the solution of babykick, but kept getting the error message: can't load python25.dll

The following worked for me. (delphi7, python26, windows xp sp3)

Open the TPythonEngine property tab and apply the following modifications

  • DllName : python26.dll
  • DllPath : c:\windows\system32\
  • UseLastknownVersion : false
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top