简体   繁体   English

我不能在python2.6下使用python for delphi

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

My environment is delphi7 and Python2.6.6, python for delphi installed. 我的环境是delphi7和Python2.6.6,安装了delphi的python。

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: test.py:

import ctypes
print 'hello'

delphi app main: delphi app主要:

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. 如果我删除“import ctypes”行,它运行正常,但如果导入ctypes则失败。

I googled and found an issue on this: http://code.google.com/p/python4delphi/wiki/P4DPython26 . 我用Google搜索并发现了一个问题: 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. 根据文章,我编译res文件并将res文件和Microsoft.VC90.CRT.manifest甚至msvcr90.dll放在项目文件夹中,在项目文件中添加XP_UAC.RES,但我仍然收到错误。 Then I reinstalled the Microsoft Visual C++ 2008 SP1 Redistributable Package, but it seems not the problem. 然后我重新安装了Microsoft Visual C ++ 2008 SP1可再发行组件包,但似乎不是问题。 Did anyone use the P4D under python2.6 successfully, please tell me how I can make it. 有没有人成功使用python2.6下的P4D,请告诉我如何制作它。

================================== ==================================
Now i have solved the ploblem by myself through reading the issues on the official website of P4D: 现在我通过阅读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 我尝试了babykick的解决方案,但不断收到错误消息: 无法加载python25.dll

The following worked for me. 以下对我有用。 (delphi7, python26, windows xp sp3) (delphi7,python26,windows xp sp3)

Open the TPythonEngine property tab and apply the following modifications 打开TPythonEngine属性选项卡并应用以下修改

  • DllName : python26.dll DllName:python26.dll
  • DllPath : c:\\windows\\system32\\ DllPath:c:\\ windows \\ system32 \\
  • UseLastknownVersion : false 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: 现在我通过阅读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  

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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