Kenny Powers
Kenny Powers

Reputation: 1274

Using shapely library with py2exe

Can't seem to figure out how to get this library to import correctly when porting with py2exe. I've tried including the shapely library in the setup file, copying all the required dll's into the dist folder, and many other things for days now. I can import the shapely.geometry features fine in python, it just doesn't seem to make it into the py2exe output file.

Any thoughts?

setup.py

from distutils.core import setup
import py2exe



setup(console=['test.py'])

test.py

from shapely.geometry import Polygon
from shapely.geometry import Point



print 'test' 

error:

C:\Users\User\Desktop\dist>test.exe Traceback (most recent call last):

File "test.py", line 1, in

File "shapely\geometry__init__.pyc", line 4, in

File "shapely\geometry\base.pyc", line 9, in

File "shapely\coords.pyc", line 8, in

File "shapely\geos.pyc", line 96, in

File "ctypes__init__.pyc", line 365, in init

WindowsError: [Error 126] The specified module could not be found

Upvotes: 0

Views: 330

Answers (1)

Gnat
Gnat

Reputation: 2921

To include the GEOS DLLs that Shapely requires, you may need to explicitly include the Shapely package via the py2exe options in setup.py.

e.g. setup.py:

...
setup(console=['test.py'],
      options={'py2exe': {'packages': ['shapely']}})

(This also works for Fiona - see https://gis.stackexchange.com/a/81821/6976)

Once the GEOS DLL is included, you may also need to explicitly exclude the Visual C++ 2008 Redistributable DLL as well - see https://stackoverflow.com/a/12153700/478380

Upvotes: 1

Related Questions