简体   繁体   中英

I can't use python for delphi under python2.6

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.

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

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  

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM