Cython .pyd and ArcGIS 10.1

Showing 1-4 of 4 messages
Cython .pyd and ArcGIS 10.1 Austin Milt 6/24/13 12:02 PM
I have built a .pyd to do calculations on a raster imported from ArcGIS 10.1. When working outside of ArcGIS, the code runs fine. However, when I attempt to import my module after importing the arcpy module, I get an import error: 

ImportError: DLL load failed: The specified module could not be found.

I was told (see ESRI forum post here) that the reason for the error is that "ArcGIS uses a different version of the msvc libraries than what you're including, so once they try to load there's a version conflict when it tries to import your local ones."

I was also told to try excluding the manifest that is embedded with my .pyd.

I have two questions:

  1. Can I tell Cython or Python not to embed the manifest? If so, are there negative consequences.
  2. Can I tell Cython to build the .pyd with the same msvc libraries used by ArcGIS 10.1 (I know where the dll files and manifest is, just not how to specify this to setup.py)

My Python version is 2.7.2, built using Visual Studio 2008, and ArcGIS 10.1. The Python install is the same that is packaged with ArcGIS
Re: [cython-users] Cython .pyd and ArcGIS 10.1 Chris Barker - NOAA Federal 6/24/13 1:53 PM
Austin,

This is a general extension-building issue, nothing specific to
Cython. And there is not a lot of Windows expertise here,
unfortunately, so you may have better luck on another list. But a few
comments:

> 10.1. When working outside of ArcGIS, the code runs fine. However, when I
> attempt to import my module after importing the arcpy module, I get an
> import error:
>
> ImportError: DLL load failed: The specified module could not be found.
>
> I was told (see ESRI forum post here) that the reason for the error is that
> "ArcGIS uses a different version of the msvc libraries than what you're
> including, so once they try to load there's a version conflict when it tries
> to import your local ones."

makes some sense, but not entirely (to me, I'm no Windows dll
expert..) -- you are importing into Python in both cases? I wonder if
Arc's module import is messing with the dll load paths somehow...Does
it matter which one you import first?

> I was also told to try excluding the manifest that is embedded with my .pyd.

sorry -- I"m still confused my manifests -- can't help here!

> Can I tell Cython or Python not to embed the manifest? If so, are there
> negative consequences.

you would be telling distutils to do that -- and I have no idea. You
can pass extra flags along to the compiler an linker, maybe there's
something to do there.

> Can I tell Cython to build the .pyd with the same msvc libraries used by
> ArcGIS 10.1 (I know where the dll files and manifest is, just not how to
> specify this to setup.py)

This is the odd part -- distutls is designed to use the same compiler,
libs, setup etc. as Pyton itself, which is what you want...

> My Python version is 2.7.2, built using Visual Studio 2008, and ArcGIS 10.1.
> The Python install is the same that is packaged with ArcGIS

If they packaged python, it's pretty odd that they would have is
linked against old dlls -- very odd!

one thing you could try, which is really grasping at straws:

install VS studio express 2010 -- it can, at least some of the time,
build extensions to a python built with VS 2008. YOu may need to
delete or rename your VS2008 install, but you should be able to get
distuitls to use the newer one, and that may help.

Also give "dependency walker" a try -- it could give you some hints.

-CHB
--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris....@noaa.gov
Re: [cython-users] Cython .pyd and ArcGIS 10.1 Austin Milt 6/25/13 6:31 AM
I am also perplexed as to why there's a compatibility issue. I've posted this issue to two other forums now (one over at python-forum.org) in hopes that someone will have an answer. 

I tried dependency walker, but grew impatient with it and abandoned it. I may give it another shot.

Thanks for your feedback. I had hoped that since the compiling steps were explained on the Cython site there might be some help here. It sounds like an issue between Python and ArcGIS though.
Re: [cython-users] Cython .pyd and ArcGIS 10.1 Austin Milt 6/25/13 7:20 AM
I had thought upon posting this topic that I would not be able to import the compiled code before arcpy, or that if I found a work-around that let me do so, it would fail some other way.

It turns out I was wrong. For whatever reason, importing the compiled code before arcpy works just fine.

I believe the issue is still relevant and I would like to get to the bottom of it and am pursuing in other forums. Thanks again


On Monday, June 24, 2013 4:53:04 PM UTC-4, Chris Barker - NOAA Federal wrote: