I have spent most of the day trying to compile an exe file from my python script and running it through the vanilla cmd command prompt. I finally managed to create the exe-file, but weirdly it only runs in the anaconda prompt and not in the cmd.
Here is the full error message/traceback:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 14, in run
module.run()
File "C:\ProgramData\Anaconda3\lib\site-packages\cx_Freeze\initscripts\Console.py", line 26, in run
exec(code, m.__dict__)
File "generateKonsekvens.py", line 1, in <module>
File "C:\ProgramData\Anaconda3\lib\site-packages\geopandas\__init__.py", line 1, in <module>
from geopandas.geoseries import GeoSeries
File "C:\ProgramData\Anaconda3\lib\site-packages\geopandas\geoseries.py", line 7, in <module>
from shapely.geometry import shape, Point
File "C:\ProgramData\Anaconda3\lib\site-packages\shapely\geometry\__init__.py", line 4, in <module>
from .base import CAP_STYLE, JOIN_STYLE
File "C:\ProgramData\Anaconda3\lib\site-packages\shapely\geometry\base.py", line 17, in <module>
from shapely.coords import CoordinateSequence
File "C:\ProgramData\Anaconda3\lib\site-packages\shapely\coords.py", line 8, in <module>
from shapely.geos import lgeos
File "C:\ProgramData\Anaconda3\lib\site-packages\shapely\geos.py", line 130, in <module>
os.path.join(sys.prefix, "Library", "lib", "geos_c.dll"),
File "C:\ProgramData\Anaconda3\lib\site-packages\shapely\geos.py", line 56, in load_dll
libname, fallbacks or []))
OSError: Could not find lib geos_c.dll or load any of its variants ['Library\\lib\\geos_c.dll'].
As you can see, it seems to be loking for something in the anaconda folder - which defeats the purpose of freezing the script. The geos_c.dll file belongs to fiona/shapely, which are in this case dependencies of the geopandas module. The geos_c.dll file can be found in the compiled folder (lib/shapely).
The script runs just fine in the normal command prompt using
python generateKonsekvens.py
in the folder.
What is causing this, and how do I fix it?
Python 3.6.3, windows 10 64 bit.
UPDATE
I tried the suggestions of jpeg, and none of them worked (could not find the dll at those locations). I tried an adhoc-solution of manually copying the dll to Library/lib/geos_c.dll
, which copied some files over, but gives the same error. I then tried with build_exe_options = {'include_files': [(os.path.join(sys.prefix, "Library", "bin", "geos_c.dll"), os.path.join("Library", "bin", "geos_c.dll"))]}
, which finds the geos_c.dll
file in the anaconda directory. I also packaged it through the windows cmd this time, and the dlls are included. The error, however, remains the same... I will now try with a new, fresh conda anaconda venv, but any other ideas are welcome in the meanwhile.