简体   繁体   中英

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

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

eg 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM