Skip to content

Python4Delphi CPU Crash #490

@Uefi1

Description

@Uefi1

Hi I'm using the Delphi XE2 compiler and python4delphi crashes with any example from the demo =(

2024-12-07_220134

I am use Python from https://github.com/adang1345/PythonWin7/tree/master Python 3.13.1

Activity

pyscripter

pyscripter commented on Dec 7, 2024

@pyscripter
Owner
Uefi1

Uefi1 commented on Dec 8, 2024

@Uefi1
Author

This was discussed in https://en.delphipraxis.net/topic/12281-python4delphi-crash-immediately-after-launch/

I see that the problem was discussed and was not fixed ?

pyscripter

pyscripter commented on Dec 8, 2024

@pyscripter
Owner

and was not fixed

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

Uefi1 commented on Dec 9, 2024

@Uefi1
Author

and was not fixed

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.

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

pyscripter commented on Dec 16, 2024

@pyscripter
Owner

Does the Embarcadero fork work for you?

Uefi1

Uefi1 commented on Dec 18, 2024

@Uefi1
Author

Does the Embarcadero fork work for you?

Hello, not

bigheart67

bigheart67 commented on Jul 30, 2025

@bigheart67

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.

  if FPythonHome <> '' then
    PyConfig_SetString(Config,
      PPWcharT(PByte(@Config) + ConfigOffests[MinorVersion, TConfigFields.home]),
      PWCharT(StringToWCharTString(FPythonHome)));
pyscripter

pyscripter commented on Jul 30, 2025

@pyscripter
Owner

@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

bigheart67 commented on Jul 30, 2025

@bigheart67

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

pyscripter commented on Jul 30, 2025

@pyscripter
Owner

I had downloaded from this repo with code download zip and extracted zip file.

Could you please try the Embarcadero fork and report whether that works?

bigheart67

bigheart67 commented on Jul 30, 2025

@bigheart67
pyscripter

pyscripter commented on Jul 31, 2025

@pyscripter
Owner

I downloaded from below:
https://github.com/embarcadero/python4delphi

It can't be. The code above is from this repo.

pyscripter

pyscripter commented on Jul 31, 2025

@pyscripter
Owner

@bigheart67 Could you please download (again) from https://github.com/embarcadero/python4delphi and test whether it works and if not where it fails?

bigheart67

bigheart67 commented on Aug 1, 2025

@bigheart67

I downloaded again from https://github.com/embarcadero/python4delphi and tested demo1.
It was crashed but the crash point is different.

  • 1 From this repo, crashed at TPythonEngine.Initialize()
    PyConfig_SetString(Config, Config.home, PWCharT(StringToWCharTString(FPythonHome)));
  • 2 From https://github.com/embarcadero/python4delphi, crashed at TPythonEngine.Initialize()
    Status := Py_InitializeFromConfig(Config);
pyscripter

pyscripter commented on Aug 1, 2025

@pyscripter
Owner

I have tried with the following python version:

*** Python 3.13.5 (tags/v3.13.5:6cb20a2, Jun 11 2025, 16:15:46) [MSC v.1943 64 bit (AMD64)] on win32. ***
>>> 

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

pyscripter commented on Aug 4, 2025

@pyscripter
Owner

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

bigheart67 commented on Aug 4, 2025

@bigheart67

My delphi version is XE5 registered.

pyscripter

pyscripter commented on Aug 5, 2025

@pyscripter
Owner

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

bigheart67 commented on Aug 5, 2025

@bigheart67

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

pyscripter commented on Aug 5, 2025

@pyscripter
Owner

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

>> import sys
>> print(sys.version)

What do you get?

bigheart67

bigheart67 commented on Aug 5, 2025

@bigheart67

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

pyscripter commented on Aug 5, 2025

@pyscripter
Owner

Same as mine. Very strange.

bigheart67

bigheart67 commented on Aug 5, 2025

@bigheart67

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, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 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, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 160, 44, 143, 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, 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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, 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

pyscripter commented on Aug 5, 2025

@pyscripter
Owner

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

pyscripter commented on Aug 5, 2025

@pyscripter
Owner

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

bigheart67 commented on Aug 5, 2025

@bigheart67

I have installed python-3140rc1/ and it works.

Thank you for your support and great works.

Uefi1

Uefi1 commented on Aug 30, 2025

@Uefi1
Author

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.

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

pyscripter commented on Aug 30, 2025

@pyscripter
Owner

Hello, under Delphi XE2 it doesn't compile at all now, there are a bunch of compiler errors !

I don't have XE2 or any other version that old. What are the compiler errors you are seeing?

Uefi1

Uefi1 commented on Aug 30, 2025

@Uefi1
Author

Hello, under Delphi XE2 it doesn't compile at all now, there are a bunch of compiler errors !

I don't have XE2 or any other version that old. What are the compiler errors you are seeing?

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

Uefi1 commented on Sep 11, 2025

@Uefi1
Author

I tried python-3.13.7 the library doesn't work with it (

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @pyscripter@Uefi1@bigheart67

        Issue actions

          Python4Delphi CPU Crash · Issue #490 · pyscripter/python4delphi