-
Notifications
You must be signed in to change notification settings - Fork 55
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
Problem with virtualenv: "Could not open python 310.dll" #4
Comments
Hi, @danieleteti! |
@lmbelo |
@pyscripter have a look at the following link: https://github.com/Embarcadero/python4delphi/blob/master/Modules/DelphiFMX/ModuleSpecs.pas We are doing something similar on Linux. It is still not supported on delphivcl and delphifmx (non-Linux). |
I don't think any of that stuff is needed at least not in Windows and quite likely not in Linux either. I don't know about Android. As a proof of concept I have modified the DemoModule project to use the LoadDLLInExtensionModule. It works well with all python versions and venvs as well. If you look at the documentation of LoadLibrary it says that if the DLL is already loaded (which is this case here), then it is used and you do not need the path. |
Ok, cool. I will have a look. Thank you. |
Another approach would be to use EnumProcessModules to find out which python dll is loaded and load that file. In linux one could use dl_iterate_phdr. The above methods should be more reliable if you need to have one extension module for all python versions. |
The example I sent you before works with a sort of Python library on Linux that doesn't provide a shared library, the symbols are on the host executable. |
I am not sure what you mean. I thought you are trying to use delphivcl/fmx with standard python distributions. In windows and linux python.exe is using a shared library pythonxy.dll or libpythonxy.so or something. I understand in Android you are making your won stuff so it could be different. |
Have you tried delphifmx with miniconda on Linux? It doesn't load a shared library. |
|
Regarding the host exported symbols, same may occur on macOS. |
Anyway, LoadDLLInExtensionModule makes sense in all systems. Python is already initialized. There is no need to initialize it again. And you need to make sure you are using the same DLL as python.exe. Try the approach in DemoModule with Delphivcl on Windows. Is incredibly simple and it works great. |
Cool. Thanks! |
I see what you meant! This is an issue on Linux and not on Windows that the original report was referring to. From what I see the standard python3 on Ubuntu and other distributions is statically linking libpython. But I tried miniconda and this also statically links libpython. I had a closer look at ModuleSpecs.pas and I see that on Linux you resolve the imports from the executable (clever!). On my Windows Ubundu WSL terminal delphifmx works with miniconda but not with the standard python3. Why is that? |
@danieleteti we have introduced venv support. Can you try again, please? |
Hi, t seems to work.
And the simple form correctly shows up. Thank you guys. From my POV this issue can be closed. ASAP I'll do more extensive tests. |
@danieleteti I'm closing this issue once it is resolved. |
This project is simply awesome! Good job guys.
I'm having a problem while using virtualenvs
I did the same test using python 3.9 and the problem is the same.
The problem doesn' happens using the system Python installation (without venvs).
Thanks
The text was updated successfully, but these errors were encountered: