Skip to content

P4D compatability with NumPy - Followup #500

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
UncleWael opened this issue May 2, 2025 · 2 comments
Closed

P4D compatability with NumPy - Followup #500

UncleWael opened this issue May 2, 2025 · 2 comments

Comments

@UncleWael
Copy link

Hello again ,

I followed the advise given in the your reply for issue #499 . I checked the imports of all the needed packages you listed and they passed.
Then i created the following test :

  1. stripped down the very same Python code of the example PyChartHTML's first tab (mpld3) : i commented out the two P4D-related lines (edge-browser) .
  2. saved the new stripped code into a test.py Python modlue ,
  3. then executed it from the Python command prompt. it executed successfully and displayed interactive chart in the browser (as seen in attached screenshot 1)
  4. I then re-run the Delphi PyChartHTML demo, it failed again (as seen in attached screenshot 2), displaying the same error message as reported previously in issue P4D compatability with NumPy #499

the test setup (versions):

  • Windows 11
  • Delphi 12.1
  • Python=3.12.3
  • Numpy=2.2.4
  • seaborn==0.13.2
  • mpld3==0.5.10
  • matplotlib==3.10.1
  • pandas==2.2.3
  • scipy==1.15.2

Image

Image

Whats now ?

@pyscripter
Copy link
Owner

pyscripter commented May 3, 2025

Add to your test.py the following:

import sys
print(sys.exec_prefix)

Is it using the same python as P4D? (AppData\Roaming\Python\Python312)

  • Your script fails when importing pandas.
  • The only difference between test.py and the P4D script is the importing of the edge-browser
  • I am pretty sure that if you run with P4D, the same code as test.py you still have the same error. (please confirm)

I cannot see how P4D is to blame for this error. P4D knows nothing about numpy, pandas or any other python module. It just runs the code using python. Also note that this code runs here fine with python 3.13, but this should not make a difference.

@UncleWael
Copy link
Author

UncleWael commented May 4, 2025

Hello Kiriakos,

At first , I want to emphasize that I do not mean to critique Python4Delphi , I really see it as a brilliant solution that will make me able to use the big scientific libraries of python in Delphi. i just ask to get everything working flawlessly .

I make the test you asked me to do. I've executed the test.py code inside P4D , and contrary to our expectations, it displayed that interactive graph in the external browser ! though not in the Edge browser, see the attached screenshot.

After further investigation , using your tip of print(sys.exec_prefix) , I discovered that P4D is accessing an forgotten anaconda3 installation rather than the default system's Python 3.12 .

So, I've removed the anaconda3 installation, fixed the registry key that the P4D engine accesses, and the error stopped. though, the edge_browser control do not render the html received.

To double check, I wrapped another component : TMemo to receive a copy of the html string. and I added the necessary lines in the python script, and re-run the demo. The HTML is received correctly from python, but neither Edge browser nor the TWebbrowser renders it well.

But since this is not a P4D issue, I want to thank you for your sincere help and for supporting this marvelous package Python4Delphi.

You may close this ticket.

Regards
Wael

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants