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 [].
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)
Windows 10
1.7.1 installed from PyPI using pipenv
@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.
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 ?
The error message was misleading: the geos_c.dll
was indeed found, but it鈥檚 dependencies we鈥檙e not. I had to install Microsoft鈥檚 VC Redistributables to get it to work.
Thanks!
Most helpful comment
The error message was misleading: the
geos_c.dll
was indeed found, but it鈥檚 dependencies we鈥檙e not. I had to install Microsoft鈥檚 VC Redistributables to get it to work.Thanks!