- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 321
Open
Description
Hi I'm using the Delphi XE2 compiler and python4delphi crashes with any example from the demo =(
I am use Python from https://github.com/adang1345/PythonWin7/tree/master Python 3.13.1
Activity
pyscripter commentedon Dec 7, 2024
This was discussed in https://en.delphipraxis.net/topic/12281-python4delphi-crash-immediately-after-launch/
Uefi1 commentedon Dec 8, 2024
I see that the problem was discussed and was not fixed ?
pyscripter commentedon Dec 8, 2024
You are using an unsupported operating system with an unsupported python version. Don't expect a fix. You may try to fix it yourself and contribute to this open source project though.
Uefi1 commentedon Dec 9, 2024
This release work 46cd7a6 , but the new version doesn’t work? What does the operating system and module for Delphi have to do with it?
pyscripter commentedon Dec 16, 2024
Does the Embarcadero fork work for you?
Uefi1 commentedon Dec 18, 2024
Hello, not
bigheart67 commentedon Jul 30, 2025
Does anyone advise me that this issue is solved?
I have a problem in same issue.
My environment is Win11, XE5, Win64, python 3.13.5 and demo1 is crashed with CPU.
Upon debugging, at TPythonEngine.Initialize() function - PyConfig_SetString is crashed.
pyscripter commentedon Jul 30, 2025
@bigheart67 This was about using python 3.12 in Windows 7. You are using Windows 11. So the issues are not related.
Which version of P4D are you using (Embarcadero fork,, GetIt, or from this repo)?
If you are using this repo, are you using the latest version (master branch)?
bigheart67 commentedon Jul 30, 2025
I had downloaded from this repo with code download zip and extracted zip file.
And execute demo1 in the Delphi XE5 with debug mode.
pyscripter commentedon Jul 30, 2025
Could you please try the Embarcadero fork and report whether that works?
bigheart67 commentedon Jul 30, 2025
I downloaded from below:
https://github.com/embarcadero/python4delphi
and get same error when execute demo1 in win64 with debug mode
https://github.com/bigheart67/GP-Shared-File/blob/main/python4delphi-error.png
pyscripter commentedon Jul 31, 2025
It can't be. The code above is from this repo.
pyscripter commentedon Jul 31, 2025
@bigheart67 Could you please download (again) from https://github.com/embarcadero/python4delphi and test whether it works and if not where it fails?
bigheart67 commentedon Aug 1, 2025
I downloaded again from https://github.com/embarcadero/python4delphi and tested demo1.
It was crashed but the crash point is different.
PyConfig_SetString(Config, Config.home, PWCharT(StringToWCharTString(FPythonHome)));
Status := Py_InitializeFromConfig(Config);
pyscripter commentedon Aug 1, 2025
I have tried with the following python version:
It works with the current state of this repo, as well as the state of the repo back in May.
I suspect this has something to do with your python version.
Can you try to uninstall and reinstall python from www.python.org on your Windows 10 machine?
11 remaining items
pyscripter commentedon Aug 4, 2025
Where is FPythonHome set? I think is should be empty.
I wonder whether this is a Delphi XE2 issue. Have you got access to the Delphi Community Edition, to check whether it works with a more recent compiler? I cannot thing of what else can explain why it runs here but not at your side. This is such a fundamental failure that many people would have complained about.
bigheart67 commentedon Aug 4, 2025
My delphi version is XE5 registered.
pyscripter commentedon Aug 5, 2025
Still it would be useful if you could install the Delphi Community edition (Delhi 12) in a virtual machine and check,
And it puzzles me that FPythonHome is not empty. Can you put a breakpoint at SetPythonHome to see where it gets its value from?
bigheart67 commentedon Aug 5, 2025
The SetPythonHome function is called from TDynamicDll.GetDllPath.
if (DLLPath = '') and not FInExtensionModule then begin {$IFDEF MSWINDOWS} if IsPythonVersionRegistered(RegVersion, Result, AllUserInstall) and (Self is TPythonEngine) then // https://github.com/python/cpython/issues/100171 TPythonEngine(Self).SetPythonHome(Result);
pyscripter commentedon Aug 5, 2025
Ah, I forgot about that. I have added this relatively recently. But the mystery remains why the initialization crashes at your side.
Can you execute python.exe and do
What do you get?
bigheart67 commentedon Aug 5, 2025
The above result is
3.13.5 (tags/v3.13.5:6cb20a2, Jun 11 2025, 16:15:46) [MSC v.1943 64 bit (AMD64)]
pyscripter commentedon Aug 5, 2025
Same as mine. Very strange.
bigheart67 commentedon Aug 5, 2025
As you know, the crash point is python function.
Py_InitializeFromConfig(Config)
So I can not step into this funcion.
Just can check the Config value:
((2, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 255, 255, 255, 255, 1, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), $14F708, $14F70C, $14F710, $14F714, $14F718, $14F71C, $14F720, $14F724, nil, $14F728, $14F72C, $14F730, $14F734, $14F738, $14FB28, $14F73C, $14F740, $14F748, $14F74C, $14F754, $14F75C, $14F764, $14F768, $14F778, $14F810, $14F788, $14F798, $14F7A8, $14F7AC, $14F7B0, $14F7B4, $14F7B8, $14F7BC, $14F7C0, $14F7C4, $14F7C8, $14F7CC, $14F7D0, $14F7D4, $14F7D8, $14F7DC, $14F7E4, $14F7EC, $14F7F0, $14F7F8, $14F7FC, $14F800, $14F804, $14F808, $14F80C, $14F810, $14F818, $14F820, $14F828, $14F830, $14F834, $14F844, $14F84C, $14F854, $14F85C, $14F864, $14F86C, $14F874, $14F828, $14F87C, $14F880, $14F888, $14F890, $14F898, $14F8A0, $14F8A4, $14F8A8, $520032, $14F8AC, $14FBF0, $6C326B)
pyscripter commentedon Aug 5, 2025
I am using this repo code. So it is different.
But the question remains. Why it fails (crashes) at your end, whilst it works for me and I suppose many other P4D users. I do not have an answer. The only difference I can see is that I use a more recent compiler.
pyscripter commentedon Aug 5, 2025
To do your work you can try python 3.14 (release candidate), with the code from this repo. 3.14 uses an entirely new way of initializing python, which is a lot more robust.
bigheart67 commentedon Aug 5, 2025
I have installed python-3140rc1/ and it works.
Thank you for your support and great works.
Uefi1 commentedon Aug 30, 2025
Hello, under Delphi XE2 it doesn't compile at all now, there are a bunch of compiler errors !
I managed to find a version that still works on Delphi XE2 and compiles without errors: https://github.com/pyscripter/python4delphi/tree/2f9efc333a6b5f4f550de6f399891e2fc8ebe907
Regarding CPU CRASH it is no longer there, apparently you fixed it, thank you very much, I am trying it on the latest version of python 3.14RC2, everything works
pyscripter commentedon Aug 30, 2025
I don't have XE2 or any other version that old. What are the compiler errors you are seeing?
Uefi1 commentedon Aug 30, 2025
Hi, you can download Delphi XE2 to a virtual machine, for example, or maybe even a portable version, I think there is one. I have already deleted the non-working libraries and configured a working one. I can’t remember what the errors were from memory.
Uefi1 commentedon Sep 11, 2025
I tried python-3.13.7 the library doesn't work with it (