marcocir 2 Posted June 16, 2021 (edited) Hi all. I have a Delphi P4D Windows application that I would to distribute as a single zip file. I use an embedded 3.8.9 64 bit version of Python in a \python folder of my application , where I have installed numpy and matplotlib, libraries that my app needs to use as well. If I try to copy the whole application folder, with \python subfolder, in another PC, and run the code where Python try to import numpy, I always get a ModuleNotFoundError : No module named 'numpy' (matplotlib is the next import module in the script, but Python script aborts on numpy import line, I think). If I don't try yo import and use these libraries my application runs just fine from the zip file. I've used Google to search for a hack but no solution seems to help: someone could suggest how to add Numpy (and MatPlotLib, I think this should be the same) to that zip file, so my customer can simply de-zip my installation file and use my Delphi application? Thanks! Edited June 16, 2021 by marcocir 1 Share this post Link to post
bernhard_LA 0 Posted June 16, 2021 (edited) can you execute matplotlib code if you use you /python folder and python.exe inside this folder? how are you setting the reference to pythonDLL and pythonDLL path in your application? I followed the config of Tpythonengine from here .... because different PC's have many different python settings / also drives me crazy ... to get one application running on different CPUs. did not want to go for my own python installation to be distributed with my application ..... Edited June 16, 2021 by bernhard_LA Share this post Link to post
marcocir 2 Posted June 16, 2021 Thank you Bernhard. No, I couldn't use the external libraries either way. Having to use the a different version of Python from any other that was eventually registered, I set the DLL's path on the OnBeforeLoad event of the Engine. The problem was only with Python external libraries Anyway, I found a solution. 1) Follow this StackOverflow answers: https://stackoverflow.com/questions/49737721/adding-packages-to-python-embedded-installation-for-windows 2) I fixed the error, and succesfully imported and used numpy and matplotlib with the embedded version of Python adding lib\site-packages entry to pythonXX._pth file, inside embedded python folder. Now I have a zip file that I can expand on a generic PC and run my P4D application with numpy and matplotlib plots (as SVG) 😉 1 Share this post Link to post