<?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 Is there a way to use ArcPy and PyGRASS tools in the same Python script? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/is-there-a-way-to-use-arcpy-and-pygrass-tools-in/m-p/484881#M37832</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I´m trying to write a Python script, that includes different ArcPy / ArcGIS commands and want to combine it with GRASS geoprocessing tools.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Unfortunately importing the GRASS libraries doesn´t work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import grass.script as grass&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ends in an error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
Traceback (most recent call last):
&amp;nbsp; File "&amp;lt;interactive input&amp;gt;", line 1, in &amp;lt;module&amp;gt;
ImportError: No module named script&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I know that GRASS GIS installs it's own Python version. Isn´t there a way to combine the ArcGIS and the GRASS GIS installation of Python? I tried copying the pygrass module (or what I thought it might be) to the "C:\Python26\ArcGIS10.0\Lib\site-packages\" folder. I´m getting a different error message, but it´s still not working.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;Traceback (most recent call last):
&amp;nbsp; File "&amp;lt;interactive input&amp;gt;", line 1, in &amp;lt;module&amp;gt;
&amp;nbsp; File "C:\Python26\ArcGIS10.0\lib\site-packages\grass\script\__init__.py", line 1, in &amp;lt;module&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; from core&amp;nbsp;&amp;nbsp; import *
&amp;nbsp; File "C:\Python26\ArcGIS10.0\lib\site-packages\grass\script\core.py", line 38, in &amp;lt;module&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; gettext.install('grasslibs', os.path.join(os.getenv("GISBASE"), 'locale'))
&amp;nbsp; File "C:\Python26\ArcGIS10.0\lib\ntpath.py", line 96, in join
&amp;nbsp;&amp;nbsp;&amp;nbsp; assert len(path) &amp;gt; 0
TypeError: object of type 'NoneType' has no len()&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In a second step I tried to connect to the .py files from GRASS GIS, but it´s still not working.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import sys
sys.path.append('C:/Program Files (x86)/GRASS GIS 6.4.3RC2/etc/python/grass/script/core.py')
sys.path.append('C:/Program Files (x86)/GRASS GIS 6.4.3RC2/etc/python/grass/script/db.py')
sys.path.append('C:/Program Files (x86)/GRASS GIS 6.4.3RC2/etc/python/grass/script/vector.py')
sys.path.append('C:/Program Files (x86)/GRASS GIS 6.4.3RC2/etc/python/grass/script/raster.py')
sys.path.append('C:/Program Files (x86)/GRASS GIS 6.4.3RC2/etc/python/grass/script/setup.py')
sys.path.append('C:/Program Files (x86)/GRASS GIS 6.4.3RC2/etc/python/grass/script/array.py')
sys.path.append('C:/Program Files (x86)/GRASS GIS 6.4.3RC2/etc/python/grass/script/task.py')

import grass.script as grass &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I´m using ArcGIS 10 and GRASS 6.4.3 on a Windows 7 64 Bit machine. Any help would be highly appreciated.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 15 Jan 2013 07:09:24 GMT</pubDate>
    <dc:creator>MartinScheiber</dc:creator>
    <dc:date>2013-01-15T07:09:24Z</dc:date>
    <item>
      <title>Is there a way to use ArcPy and PyGRASS tools in the same Python script?</title>
      <link>https://community.esri.com/t5/python-questions/is-there-a-way-to-use-arcpy-and-pygrass-tools-in/m-p/484881#M37832</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I´m trying to write a Python script, that includes different ArcPy / ArcGIS commands and want to combine it with GRASS geoprocessing tools.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Unfortunately importing the GRASS libraries doesn´t work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import grass.script as grass&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ends in an error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
Traceback (most recent call last):
&amp;nbsp; File "&amp;lt;interactive input&amp;gt;", line 1, in &amp;lt;module&amp;gt;
ImportError: No module named script&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I know that GRASS GIS installs it's own Python version. Isn´t there a way to combine the ArcGIS and the GRASS GIS installation of Python? I tried copying the pygrass module (or what I thought it might be) to the "C:\Python26\ArcGIS10.0\Lib\site-packages\" folder. I´m getting a different error message, but it´s still not working.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;Traceback (most recent call last):
&amp;nbsp; File "&amp;lt;interactive input&amp;gt;", line 1, in &amp;lt;module&amp;gt;
&amp;nbsp; File "C:\Python26\ArcGIS10.0\lib\site-packages\grass\script\__init__.py", line 1, in &amp;lt;module&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; from core&amp;nbsp;&amp;nbsp; import *
&amp;nbsp; File "C:\Python26\ArcGIS10.0\lib\site-packages\grass\script\core.py", line 38, in &amp;lt;module&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; gettext.install('grasslibs', os.path.join(os.getenv("GISBASE"), 'locale'))
&amp;nbsp; File "C:\Python26\ArcGIS10.0\lib\ntpath.py", line 96, in join
&amp;nbsp;&amp;nbsp;&amp;nbsp; assert len(path) &amp;gt; 0
TypeError: object of type 'NoneType' has no len()&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In a second step I tried to connect to the .py files from GRASS GIS, but it´s still not working.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import sys
sys.path.append('C:/Program Files (x86)/GRASS GIS 6.4.3RC2/etc/python/grass/script/core.py')
sys.path.append('C:/Program Files (x86)/GRASS GIS 6.4.3RC2/etc/python/grass/script/db.py')
sys.path.append('C:/Program Files (x86)/GRASS GIS 6.4.3RC2/etc/python/grass/script/vector.py')
sys.path.append('C:/Program Files (x86)/GRASS GIS 6.4.3RC2/etc/python/grass/script/raster.py')
sys.path.append('C:/Program Files (x86)/GRASS GIS 6.4.3RC2/etc/python/grass/script/setup.py')
sys.path.append('C:/Program Files (x86)/GRASS GIS 6.4.3RC2/etc/python/grass/script/array.py')
sys.path.append('C:/Program Files (x86)/GRASS GIS 6.4.3RC2/etc/python/grass/script/task.py')

import grass.script as grass &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I´m using ArcGIS 10 and GRASS 6.4.3 on a Windows 7 64 Bit machine. Any help would be highly appreciated.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jan 2013 07:09:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-there-a-way-to-use-arcpy-and-pygrass-tools-in/m-p/484881#M37832</guid>
      <dc:creator>MartinScheiber</dc:creator>
      <dc:date>2013-01-15T07:09:24Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to use ArcPy and PyGRASS tools in the same Python script?</title>
      <link>https://community.esri.com/t5/python-questions/is-there-a-way-to-use-arcpy-and-pygrass-tools-in/m-p/484882#M37833</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I´m trying to write a Python script, that includes different ArcPy / ArcGIS commands and want to combine it with GRASS geoprocessing tools.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This will only work if:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1) The versionsof Python are the same (and both 32 or 64)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2) The python libraries in use are the same version&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have been pretty sucessful pulling in my EPD library by simply adding them to the Desktop10.pth file, or adding the paths I need to the PYTHONPATH. sys.path.append should work as well, but it is a more cumbersome way to go.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, I would imagine there are different flavors of GDAL and other libraries at play here, so I don't know if this is doable.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Perhaps your arcpy script could write out a python script and then execute it using the GRASS python in its native environment through a system command line using the &lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;"&gt;subprocess &lt;/SPAN&gt;&lt;SPAN&gt;module. This would be ugly but may be the only way.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jan 2013 18:44:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-there-a-way-to-use-arcpy-and-pygrass-tools-in/m-p/484882#M37833</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2013-01-15T18:44:57Z</dc:date>
    </item>
  </channel>
</rss>

