Skip to content
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

"The procedure entry point (...) could not be located" on windows #2201

Closed
reasv opened this issue Jul 12, 2024 · 8 comments
Closed

"The procedure entry point (...) could not be located" on windows #2201

reasv opened this issue Jul 12, 2024 · 8 comments

Comments

@reasv
Copy link

reasv commented Jul 12, 2024

I was having the same issue as #2198 and decided to follow your instructions at #2198 (comment)
So I uninstalled every python distribution I have including conda from my system before installing python 3.12 from the windows store.

Now I get a different error:
e2sAbDcWcv
This happens on import, yes it shows up as a window. There's multiple, one for each library.

@liZe
Copy link
Member

liZe commented Jul 12, 2024

Hi!

Did you try to restart your computer? It can help if you installed/uninstalled some packages.

Otherwise, does this libgobject-2.0-0.dll file still exists on your system?

@reasv
Copy link
Author

reasv commented Jul 13, 2024

The file does exist
image
Restarting did not solve the problem.
There's a similar error for each of the dlls including harfbuzz. It seems to be loading them but not finding these procedure entry points.

@reasv
Copy link
Author

reasv commented Jul 13, 2024

I found out that after dismissing these (4-5!) error messages, weasyprint works in interactive python.
I was able to do this

Python 3.12.4 (tags/v3.12.4:8e8a4ba, Jun  6 2024, 19:30:16) [MSC v.1940 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import weasyprint
>>>
(process:25672): GLib-GIO-WARNING **: 08:40:38.818: Unexpectedly, UWP app `Microsoft.OutlookForWindows_1.2024.111.100_x64__8wekyb3d8bbwe' (AUMId `Microsoft.OutlookForWindows_8wekyb3d8bbwe!Microsoft.OutlookforWindows') supports 1 extensions but has no verbs

(process:25672): GLib-GIO-WARNING **: 08:40:38.912: Unexpectedly, UWP app `Microsoft.ScreenSketch_11.2405.32.0_x64__8wekyb3d8bbwe' (AUMId `Microsoft.ScreenSketch_8wekyb3d8bbwe!App') supports 29 extensions but has no verbs

(process:25672): GLib-GIO-WARNING **: 08:40:38.958: Unexpectedly, UWP app `Clipchamp.Clipchamp_3.1.10920.0_neutral__yxz26nhyzhsrt' (AUMId `Clipchamp.Clipchamp_yxz26nhyzhsrt!App') supports 41 extensions but has no verbs

>>> from weasyprint import HTML
>>> HTML('https://weasyprint.org')
<weasyprint.HTML object at 0x0000024B6688DE50>
>>> html = HTML('https://weasyprint.org')
>>> html.write_pdf("test.pdf")
>>>

And get a working PDF with the expected content.

But these error windows, along with those console errors, show up every time I import weasyprint and that's a problem and probably not something that should happen.
image

@liZe
Copy link
Member

liZe commented Jul 13, 2024

I found out that after dismissing these (4-5!) error messages, weasyprint works in interactive python.

Wow, that’s another problem on Windows I’ve never seen before!

I really think that you have multiple versions of these libraries installed on your computer. Many people get this error with many apps, that’s just another DLL hell problem.

https://stackoverflow.com/questions/20854074/the-procedure-entry-point-could-not-be-found

About the GLib warning, it looks like it’s a common message too: 3b1b/manim#1556. Uninstalling or reinstalling the concerned apps seems to fix the problem.

These two problems come from interactions with other programs installed on your system. As I’ve not used Windows for a very long time, I won’t be able to help you with that, you’ll probably get more help from Windows masters on StackOverflow.

If you want to avoid these problems, you can also try to use WSL, or the Windows executable we provide.

@reasv
Copy link
Author

reasv commented Jul 13, 2024

you can also try to use WSL, or the Windows executable we provide.

Unfortunately both of these choices aren't realistic for my use case. The executable works just fine with no errors, but the reason I am even trying to get weasyprint to work is I am using a different library that calls weasyprint.
Using WSL would work but I want windows users to be able to run my project without needing WSL.
Once I solve this problem on my machine I might just build an installer to try and make dependencies work.

I can say that I did have GTK3-runtime installed, I found out by searching the filename with Everything.
Now it seems there's only one version of the library in PATH:
image

However, after creating the new venv, and installing weasyprint again, I now get the original error back:

OSError: cannot load library 'gobject-2.0-0': error 0x7e.  Additionally, ctypes.util.find_library() did not manage to locate a library called 'gobject-2.0-0'

But the mingw directory with the library is in PATH. I verified it.

So I tried this:

>>> print(ctypes.util.find_library('gobject-2.0-0'))
None
>>> print(ctypes.util.find_library('libgobject-2.0-0'))
C:\msys64\mingw64\bin\libgobject-2.0-0.dll
>>> ctypes.CDLL(ctypes.util.find_library('libgobject-2.0-0'))
<CDLL 'C:\msys64\mingw64\bin\libgobject-2.0-0.dll', handle 7ff95ded0000 at 0x148eaa8cf80>
>>>

It works when loaded as libgobject, but not as gobject. It seems on msys2 the name is different?
What could this mean?

I tried duplicating libgobject-2.0-0.dll and renaming the copy to gobject-2.0-0.dll
Now this works:

>>> ctypes.util.find_library('gobject-2.0-0')
'C:\\msys64\\mingw64\\bin\\gobject-2.0-0.dll'
>>> ctypes.CDLL(ctypes.util.find_library('gobject-2.0-0'))
<CDLL 'C:\msys64\mingw64\bin\gobject-2.0-0.dll', handle 7ff94ccc0000 at 0x148eaa8cd10>

Now, when trying to import weasyprint, it no longer complains about gobject, instead complaining about pango.
So I decided to copy and rename all of the dlls to see what would happen

I copied the entire bin directory from mingw64, created bin2 and renamed all the lib*.dll files into *.dll
and put bin2 in PATH

I now get this error

OSError: cannot load library 'C:\msys64\mingw64\bin2\gobject-2.0-0.dll': error 0x7e

I think this is because it's no longer finding its own dependencies since I changed the filenames.

So I tried one last thing, copying all DLLs from bin2 to bin and deleting bin2.

OSError: cannot load library 'C:\msys64\mingw64\bin\gobject-2.0-0.dll': error 0x7e

I'm out of ideas.

@liZe
Copy link
Member

liZe commented Jul 13, 2024

I can say that I did have GTK3-runtime installed, I found out by searching the filename with Everything.

OK, that’s your problem, you have 2 different versions of the libraries installed.

Now it seems there's only one version of the library in PATH:

Python doesn’t use PATH anymore to find libraries. Instead, we now have to declare paths where to look for libraries, as it’s done here:

dll_directories = os.getenv(
'WEASYPRINT_DLL_DIRECTORIES',
'C:\\Program Files\\GTK3-Runtime Win64\\bin;'
'C:\\msys64\\mingw64\\bin').split(';')
for dll_directory in dll_directories:
with suppress((OSError, FileNotFoundError)):
os.add_dll_directory(dll_directory)

The problem may come the fact that you have both MSYS2 and GTK3 libraries installed, as WeasyPrint looks in these two folders by default. Maybe setting WEASYPRINT_DLL_DIRECTORIES to C:\msys64\mingw64\bin only will fix the problem.

It works when loaded as libgobject, but not as gobject. It seems on msys2 the name is different? What could this mean?

I tried duplicating libgobject-2.0-0.dll and renaming the copy to gobject-2.0-0.dll

Please don’t do this, you don’t have to rename the files. WeasyPrint already tries different names (including libgobject-2.0-0.dll).

@reasv
Copy link
Author

reasv commented Jul 13, 2024

OK, that’s your problem, you have 2 different versions of the libraries installed.

I had uninstalled GTK3-runtime already. It's gone, the DLLs too.
Uninstalled MSYS2. Deleted venv. Made sure all files are gone. No more gobject DLLs in path.
Reinstalled MSYS2. Ran pacman command again to install pango.

Created new venv with microsoft store python (checked with where python)
Activated venv.
installed weasyprint.

OSError: cannot load library 'gobject-2.0-0': error 0x7e.  Additionally, ctypes.util.find_library() did not manage to locate a library called 'gobject-2.0-0'

Still got this error, despite deleting GTK-3 runtime and all its DLLs.

>>> os.environ["WEASYPRINT_DLL_DIRECTORIES"] = r"C:\msys64\mingw64\bin"
>>> import weasyprint
>>>

Ok, this finally worked. No errors. Now I need to get it to all work with poetry but it seems my issue is solved.

@reasv reasv closed this as completed Jul 13, 2024
@reasv
Copy link
Author

reasv commented Jul 13, 2024

Thanks for your help. It seems in the end a combination of different issues caused my problems

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