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

时间:2011-03-17 17:04:11

标签: python delphi python4delphi

我的环境是delphi7和Python2.6.6,安装了delphi的python。

但是当我运行测试应用程序时,我遇到了运行时错误。

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;

如果我删除“import ctypes”行,它会运行正常,但如果导入ctypes则会失败。

我用Google搜索并发现了一个问题: http://code.google.com/p/python4delphi/wiki/P4DPython26

根据文章,我编译res文件并将res文件和Microsoft.VC90.CRT.manifest甚至msvcr90.dll放在项目文件夹中,在项目文件中添加XP_UAC.RES,但我仍然得到错误。 然后我重新安装了Microsoft Visual C ++ 2008 SP1可再发行组件包,但似乎不是问题。 有没有人成功使用python2.6下的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.

顺便说一句,我并不是要把我的每一个问题都弄糊涂,如果确实如此,我很抱歉,所以如果你没有自己尝试,请不要随意投入别人的问题。< / p>

2 个答案:

答案 0 :(得分:1)

也许我没有清楚地描述我的问题。 现在我通过阅读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  

答案 1 :(得分:1)

我尝试了 babykick 的解决方案,但不断收到错误消息: 无法加载python25.dll

以下对我有用。 (delphi7,python26,windows xp sp3)

  

打开TPythonEngine属性选项卡并应用   以下修改

     
      
  • DllName:python26.dll
  •   
  • DllPath:c:\ windows \ system32 \
  •   
  • UseLastknownVersion:false
  •