DominicE 1 Posted February 24, 2021 (edited) Hello, I'm trying to get NumPy working with Demo34. The project I'm working on is using the exact same approach as Demo34 for dynamically switching Python versions by recreating the engine, therefore Demo34 is the perfect example. I was advised to unload the DLL's, so I tried unloading the DLL's which seemed to be loaded by NumPy including "_multiarray_umath.cp39-win32.pyd", however, sadly this was still causing errors. I don't know enough about NumPy to know why it's causing access violations when I try to unload its DLL's. Please assist me with using NumPy with Demo34 if possible, thank you. p.s. It's easy to recreate this issue by running Demo34, replacing the Python script with a very simple "import numpy" statement, executing the Python script, and then switching to and from a different Python version. On trying to execute the Python script again, errors will be raised and it's related to NumPy not liking to be re-initialised as far as I know. Edited February 24, 2021 by DominicE Share this post Link to post
pyscripter 694 Posted February 24, 2021 Did you see my answer in Demo34 + NumPy · Issue #287 · pyscripter/python4delphi (github.com)? Did you try what I suggested there? Share this post Link to post
DominicE 1 Posted February 24, 2021 Yes, I tried unloading the DLL's that the debugger was reporting were being loaded when I ran the script, including the _multiarray_umath.cp36-win32.pyd module that was causing the error, but it causes further access violations. I don't know whether there's a specific order in which I need to unload the DLL's or something like that. Sadly I don't know enough about NumPy and what it's doing under the hood in order to know any better than to simply unload all the modules that were reported by the debugger. Share this post Link to post
DominicE 1 Posted February 24, 2021 Ah, I've progressed a bit further, I've now got it throwing up a Python type error when I rerun the script. I wasn't unloading one of the DLL's properly. Now that I've corrected that let me play around and see if I can determine the cause of the type error. Share this post Link to post
DominicE 1 Posted February 24, 2021 (edited) Alright I managed to get it working which is great, thanks for the advice. However, it still ran into issues even after unloading what I thought was all of the NumPy DLL's. It required me to also unload the python3 and ctypes DLL as well as some others, which I would have thought P4D would be handling under the hood, unsure as to why they are hanging around in memory, bit clunky and prone to falling over having to specifier so many quite-specific DLL's. Edited February 24, 2021 by DominicE Share this post Link to post
DominicE 1 Posted February 25, 2021 I'm back with a follow up question related to this same topic. If it possible to detect which modules have been loaded by the Python script since starting P4D? I'm manually listing NumPy modules to unload, but they can differ by Python version I'm executing and trying to list all of the different DLL names would be ludicrous. I need some sure fire way of unloading all DLL's that Python loaded during its execution, but only the DLL's within that Python script, I don't want to accidentally unload any Delphi related DLL's or DLL's that P4D relies on to function. Thanks for any assistance you can offer. 1 Share this post Link to post
gabiF 0 Posted July 23 @DominicE, I am having the same problem. Could you please send me which DLLs you unloaded? Share this post Link to post