<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Conflict arcpy (Arc 10) and gdal? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/conflict-arcpy-arc-10-and-gdal/m-p/699070#M54189</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Definitely something going on with the Python distribution in Arc 10. I was also having massive problems with scipy and matplotlib. I'm not sure if this is going a bit overboard, but I finally gave up on the arc distribution and installed python(x,y). It took me several days to figure out how to do this, but it was worth it in the end. Instructions are below if you're interested.... &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1) Install ArcGis10 without python, or just uninstall python&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2) Download Python(x,y) from &lt;/SPAN&gt;&lt;A href="http://www.pythonxy.com/"&gt;http://www.pythonxy.com/&lt;/A&gt;&lt;SPAN&gt; and install, making sure you select "custom directories" so that python is installed in C:\Python26. If installing on a 64 bit machine, do not include GDAL 1.6 �?? it won�??t work. Instead, go to &lt;/SPAN&gt;&lt;A href="http://www.lfd.uci.edu/~gohlke/pythonlibs/"&gt;http://www.lfd.uci.edu/~gohlke/pythonlibs/&lt;/A&gt;&lt;SPAN&gt; and install&amp;nbsp; GDAL-1.8.0.win32-py2.6.exe.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;3) Create a file called Desktop10.pth, which&amp;nbsp; should contain these lines:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;C:\Program Files (x86)\ArcGIS\Desktop10.0\bin&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;C:\Program Files (x86)\ArcGIS\Desktop10.0\ArcToolbox\Script&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;4) Place the file in the python installation directory: �??C:\Python26�??&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;5) Open IDLE and try �??import arcpy�??&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 28 Jun 2011 21:50:57 GMT</pubDate>
    <dc:creator>ChrisBater</dc:creator>
    <dc:date>2011-06-28T21:50:57Z</dc:date>
    <item>
      <title>Conflict arcpy (Arc 10) and gdal?</title>
      <link>https://community.esri.com/t5/python-questions/conflict-arcpy-arc-10-and-gdal/m-p/699066#M54185</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Dear all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Since a year or so, I happily combine the arctools with gdal and python functionality. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;However, since I upgraded to ArcGIS 10 I ran into a number of problems.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My biggest issue is this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The following code works fine:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
import arcpy

arcpy.CheckOutExtension("Spatial")
raster = 'E:/temp/raster.img'
shapefile = 'E:/temp/shapefile.shp'

mask = arcpy.sa.ExtractByMask(raster,shapefile)
mask.save('E:/temp/test.img')
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, when I add 'from osgeo import gdal' at the very beginning, I get an error message that some conversion from arcobjects to python object couldn't finish:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
from osgeo import gdal
import arcpy

arcpy.CheckOutExtension("Spatial")
raster = 'E:/temp/raster.img'
shapefile = 'E:/temp/shapefile.shp'

mask = arcpy.sa.ExtractByMask(raster,shapefile)
mask.save('E:/temp/test.img')

&amp;gt;&amp;gt;&amp;gt; 
Traceback (most recent call last):
&amp;nbsp; File "E:\temp\ivan\testing3.py", line 8, in &amp;lt;module&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; mask = arcpy.sa.ExtractByMask(raster,shapefile)
&amp;nbsp; File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\sa\Functions.py", line 6726, in ExtractByMask
&amp;nbsp;&amp;nbsp;&amp;nbsp; in_mask_data)
&amp;nbsp; File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\sa\Utils.py", line 47, in swapper
&amp;nbsp;&amp;nbsp;&amp;nbsp; result = wrapper(*args, **kwargs)
&amp;nbsp; File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\sa\Functions.py", line 6722, in wrapper
&amp;nbsp;&amp;nbsp;&amp;nbsp; out_raster)
&amp;nbsp; File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 474, in &amp;lt;lambda&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; return lambda *args: val(*gp_fixargs(args))
ExecuteError: ERROR 010024: Error during conversion.
Failed to execute (ExtractByMask).
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and if I *first* import arcpy and *then* import gdal, the gdal DLL could not be found:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
import arcpy
from osgeo import gdal

arcpy.CheckOutExtension("Spatial")
raster = 'E:/temp/raster.img'
shapefile = 'E:/temp/shapefile.shp'

mask = arcpy.sa.ExtractByMask(raster,shapefile)
mask.save('E:/temp/test.img')

&amp;gt;&amp;gt;&amp;gt; 
Traceback (most recent call last):
&amp;nbsp; File "E:\temp\ivan\testing3.py", line 2, in &amp;lt;module&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; from osgeo import gdal
&amp;nbsp; File "C:\Python26\ArcGIS10.0\lib\site-packages\osgeo\gdal.py", line 7, in &amp;lt;module&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; import _gdal
ImportError: DLL load failed: The specified procedure could not be found.
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there anyone else experiencing this, and is this due to my settings? or is there some conflict between ArcGIS 10 and gdal?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have ArcGIS 10 build 2800 (I thought I installed SP1) + gdalwin32_1.6, and windows XP PRO 32 bit.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Since I'm lost now, any ideas would be great,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Niels&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jun 2011 09:05:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/conflict-arcpy-arc-10-and-gdal/m-p/699066#M54185</guid>
      <dc:creator>NielsAnders</dc:creator>
      <dc:date>2011-06-01T09:05:00Z</dc:date>
    </item>
    <item>
      <title>Re: Conflict arcpy (Arc 10) and gdal?</title>
      <link>https://community.esri.com/t5/python-questions/conflict-arcpy-arc-10-and-gdal/m-p/699067#M54186</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi-&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Sounded unhappily familiar.&amp;nbsp; I had similar loss of functionality, including the 'depends-which-I-import-first' type behavior.&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://trac.osgeo.org/gdal/ticket/4087"&gt;http://trac.osgeo.org/gdal/ticket/4087&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;May not be a 'gdal bug', but worth reporting anywhere.&amp;nbsp; For the meanwhile, I'm maintaining multiple installs of Python 2.6.x, and leaning on os.system() to start other python instances. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Good luck!&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Daryl&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jun 2011 16:18:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/conflict-arcpy-arc-10-and-gdal/m-p/699067#M54186</guid>
      <dc:creator>DarylVan_Dyke</dc:creator>
      <dc:date>2011-06-01T16:18:32Z</dc:date>
    </item>
    <item>
      <title>Re: Conflict arcpy (Arc 10) and gdal?</title>
      <link>https://community.esri.com/t5/python-questions/conflict-arcpy-arc-10-and-gdal/m-p/699068#M54187</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the info, at least I know I'm not the only one...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'll think about a workaround so I don't have to import both at the same time..&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Jun 2011 12:28:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/conflict-arcpy-arc-10-and-gdal/m-p/699068#M54187</guid>
      <dc:creator>NielsAnders</dc:creator>
      <dc:date>2011-06-02T12:28:03Z</dc:date>
    </item>
    <item>
      <title>Re: Conflict arcpy (Arc 10) and gdal?</title>
      <link>https://community.esri.com/t5/python-questions/conflict-arcpy-arc-10-and-gdal/m-p/699069#M54188</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I was having issues getting "import gdal" to work also. Some stuff going on with the python environment in ArcGIS 10. I ended up getting gdal working with python 2.6 (not from within ArcGIS desktop). Once I got that working I then copied the gdal16.dll(not the dll installed with ArcGIS) to the C:\WINDOWS\system32 folder and now I can import gdal from the python interpreter instantiated from within a ArcGIS desktop application. I really don't know what is going on here but It must have someting to do with the unique way ArcGIS 10 pooling a single instance the python interpreter to be to be shared with all Python based GP tool calls and how this environment is being setup.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I noticed the IDLE IDE interactive command window has the line "IDLE 2.6.5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ==== No Subprocess ====". I have never seen this before and is maybe a bit of a hit of how the interpreter if fired up by ArcGIS 10. Wierd stuff!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If anyone has some insight, please share it.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Jun 2011 13:09:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/conflict-arcpy-arc-10-and-gdal/m-p/699069#M54188</guid>
      <dc:creator>axel99</dc:creator>
      <dc:date>2011-06-24T13:09:59Z</dc:date>
    </item>
    <item>
      <title>Re: Conflict arcpy (Arc 10) and gdal?</title>
      <link>https://community.esri.com/t5/python-questions/conflict-arcpy-arc-10-and-gdal/m-p/699070#M54189</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Definitely something going on with the Python distribution in Arc 10. I was also having massive problems with scipy and matplotlib. I'm not sure if this is going a bit overboard, but I finally gave up on the arc distribution and installed python(x,y). It took me several days to figure out how to do this, but it was worth it in the end. Instructions are below if you're interested.... &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1) Install ArcGis10 without python, or just uninstall python&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2) Download Python(x,y) from &lt;/SPAN&gt;&lt;A href="http://www.pythonxy.com/"&gt;http://www.pythonxy.com/&lt;/A&gt;&lt;SPAN&gt; and install, making sure you select "custom directories" so that python is installed in C:\Python26. If installing on a 64 bit machine, do not include GDAL 1.6 �?? it won�??t work. Instead, go to &lt;/SPAN&gt;&lt;A href="http://www.lfd.uci.edu/~gohlke/pythonlibs/"&gt;http://www.lfd.uci.edu/~gohlke/pythonlibs/&lt;/A&gt;&lt;SPAN&gt; and install&amp;nbsp; GDAL-1.8.0.win32-py2.6.exe.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;3) Create a file called Desktop10.pth, which&amp;nbsp; should contain these lines:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;C:\Program Files (x86)\ArcGIS\Desktop10.0\bin&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;C:\Program Files (x86)\ArcGIS\Desktop10.0\ArcToolbox\Script&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;4) Place the file in the python installation directory: �??C:\Python26�??&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;5) Open IDLE and try �??import arcpy�??&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Jun 2011 21:50:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/conflict-arcpy-arc-10-and-gdal/m-p/699070#M54189</guid>
      <dc:creator>ChrisBater</dc:creator>
      <dc:date>2011-06-28T21:50:57Z</dc:date>
    </item>
    <item>
      <title>Re: Conflict arcpy (Arc 10) and gdal?</title>
      <link>https://community.esri.com/t5/python-questions/conflict-arcpy-arc-10-and-gdal/m-p/699071#M54190</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I just ran into this problem!&amp;nbsp; I am not sure how this solution is going to impact arcpy related functionality, however I just figured out how to successfully import both arcpy and osgeo.ogr. BTW I am using gdal/ogr version 1.6.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For some reason if you import arcpy first and ogr/gdal second, gdal is no longer able to find the dll's that it requires.&amp;nbsp; I have managed to determine that if you add the path to your gdal/bin installation directory back into the os.environ['PATH'] environment variable then gdal seems to be able to find the dll's it requires.&amp;nbsp; The following lines solved the problem for me:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import os&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;environList = os.environ['PATH'].split(';')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;environList.insert(0, r'C:\Program Files\gdalwin32-1.6\bin')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;os.environ['PATH'] = ';'.join(environList)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import osgeo.ogr&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would guess the problem is related to the fact that esri uses the gdal16.dll, so when arcpy is imported something happens which prevents ogr from finding its various dll's.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I wonder if after these imports have been implemented whether arcpy functions/methods that use the esri version of the gdal16.dll will continue to work.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Jul 2011 17:45:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/conflict-arcpy-arc-10-and-gdal/m-p/699071#M54190</guid>
      <dc:creator>KevinNetherton</dc:creator>
      <dc:date>2011-07-21T17:45:13Z</dc:date>
    </item>
  </channel>
</rss>

