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

Can't package with pipenv and cx_freeze: OSError: Could not find lib geos_c.dll or load any of its variants [] #986

Closed
ypicard opened this issue Sep 16, 2020 · 3 comments
Labels
invalid Not a problem with shapely

Comments

@ypicard
Copy link

ypicard commented Sep 16, 2020

Expected behavior and actual behavior.

When freezing my python3.8 program into an msi using cx_freeze, the msi works on the computer it was built on but not on other hosts.
The error message is: OSError: Could not find lib geos_c.dll or load any of its variants [].

Steps to reproduce the problem.

Pipfile:

[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[packages]
cx_Freeze = "==6.2"
shapely = "==1.7.1"

[requires]
python_version = "3.8"

[scripts]
build = "python setup.py bdist_msi"

setup.py:

from cx_Freeze import setup, Executable

if __name__ == "__main__":
    APP = Executable(
        script="test.py",
        base=None,
        targetName="test",  # executable name avaiable in cli after installation
    )

    setup(
        name="test",
        options={
            "build_exe": {},
            "bdist_msi": {
                "add_to_path": True,
                "all_users": True,  # require admin rights
            },
        },
        executables=[APP],
    )

test.py:

from shapely.geometry import LineString

pallet_line_string = LineString(
    [
        (0, 0),
        (10, 0),
        (10, 20),
        (0, 20),
        (0, 0),
    ]
)
print(pallet_line_string)

Operating system

Windows 10

Shapely version and provenance

1.7.1 installed from PyPI using pipenv

@sgillies sgillies added the invalid Not a problem with shapely label Sep 16, 2020
@sgillies
Copy link
Contributor

@ypicard I'm sorry about the trouble, but this is not a shapely issue. You must work out how to include a compatible geos_c.dll in your bundle. Here is how we do it for shapely wheels built on appveyor: https://github.com/Toblerity/Shapely/blob/maint-1.7/appveyor.yml#L84.

@ypicard
Copy link
Author

ypicard commented Sep 17, 2020

The thing is, the dlls are already packaged correctly. I can find them in the installation directory of my program (C:\Program Files (x86)\my_program\lib\shapely\DLLs). They seem to be correctly bundled.
The problem is that shapely can't load them correctly. I printed the path at geos.py:166 and both egg_dlls and wininst_dlls look correct.
What is happening ?

@ypicard
Copy link
Author

ypicard commented Sep 17, 2020

The error message was misleading: the geos_c.dll was indeed found, but it’s dependencies we’re not. I had to install Microsoft’s VC Redistributables to get it to work.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid Not a problem with shapely
Projects
None yet
Development

No branches or pull requests

2 participants