GRASS, ArcGIS, and Python incompatibilties

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

GRASS, ArcGIS, and Python incompatibilties

Michael Barton
I thought I'd seen this somewhere on the list, but I can't seem to find it. If there is a posted answer, perhaps someone could point me to it. Otherwise, hopefully, someone can offer an answer.

I'm working with a colleague who has Windows 7 and ArcGIS installed. He installed GRASS for Windows, but it won't launch due to some combination of Python/wxPython incompatibility. We're pretty sure that it has to do with the version of Python he had to install with ArcGIS. The ArcGIS Python is 2.6, but GRASS for Windows comes with Python 2.7. Is there some configuration setting to get around this?

Michael
_____________________
C. Michael Barton
Visiting Scientist, Integrated Science Program
National Center for Atmospheric Research &
University Corporation for Atmospheric Research
303-497-2889 (voice)

Director, Center for Social Dynamics & Complexity 
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University


_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Reply | Threaded
Open this post in threaded view
|

Re: GRASS, ArcGIS, and Python incompatibilties

gene
at work, we use ArcGIS (Python 2.6), GRASS GIS (Python 2.7) QGIS (Python 2.7) and a standard Python (version 2.5) installed on Windows XP without problem (in the Windows Registry, only Python 2.5 and the Python 2.6 of ArcGIS)

Arcpy
- has no wxPython module:
  >>> import wx
   Runtime error <type 'exceptions.ImportError'>: No module named wx
  >>> from wxPython.wx import *
  Runtime error <type 'exceptions.ImportError'>: No module named wxPython.wx
  >>> from wxPython import *
  Runtime error <type 'exceptions.ImportError'>: No module named wxPython

- but we can use modules of Python 2.5 (without dlls...)
  >>> import subprocess
  >>> argument= str(geom)
  >>> trait = subprocess.Popen(['C:/Python25/python.exe','d:/test/testshapely.py',argument], stdout=subprocess.PIPE)
 >>> wkt= trait.stdout.read()
 >>> print wkt
'LINESTRING (232278.9235196237900000....

QGIS or GRASS GIS
The same thing is true (see http://www.portailsig.org/content/qgis-lancer-des-scripts-python-ou-des-commandes-shell-depuis-la-console-python-ou-avec-scrip, in French)

When we try to use Arcpy in GRASS GIS or QGIS, the error message is
  import sys
  sys.path.append('C:\\Program Files\\ArcGIS\\Desktop10.0\\arcpy\\')
  sys.path.append('C:\\Program Files\\ArcGIS\\Desktop10.0\\Bin\\')
  import arcpy
  Traceback (most recent call last):
 ....
  ImportError: Module use of python26.dll conflicts with this version of Python.

same thing if i use subprocess.Popen

If i do the same thing in ArcPy
    sys.path.append('C:\\Program Files\\GRASS 6.4.2\\Python27\\Lib\\site-packages')
    import wx
    Traceback (most recent call last):
    ...
    ImportError: Module use of python27.dll conflicts with this version of Python.


so i do not think that the problem comes from the different versions of Python
 

Reply | Threaded
Open this post in threaded view
|

Re: GRASS, ArcGIS, and Python incompatibilties

davidalvarez76
At work we use

Windows 7 ( Arcgis 10 SP4 and GRASS) without any problem

Sent from my iPhone
David Alvarez

On Jun 29, 2012, at 4:32 AM, gene <[hidden email]> wrote:

> at work, we use ArcGIS (Python 2.6), GRASS GIS (Python 2.7) QGIS (Python 2.7)
> and a standard Python (version 2.5) installed on Windows XP without problem
> (in the Windows Registry, only Python 2.5 and the Python 2.6 of ArcGIS)
>
> *Arcpy*
> - has no wxPython module:
>>>> import wx
>   Runtime error <type 'exceptions.ImportError'>: No module named wx
>>>> from wxPython.wx import *
>  Runtime error <type 'exceptions.ImportError'>: No module named wxPython.wx
>>>> from wxPython import *
>  Runtime error <type 'exceptions.ImportError'>: No module named wxPython
>
> - but we can use modules of Python 2.5 (without dlls...)
>>>> import subprocess
>>>> argument= str(geom)
>>>> trait =
> subprocess.Popen(['C:/Python25/python.exe','d:/test/testshapely.py',argument],
> stdout=subprocess.PIPE)
>>>> wkt= trait.stdout.read()
>>>> print wkt
> 'LINESTRING (232278.9235196237900000....
>
> *QGIS or GRASS GIS*
> The same thing is true (see
> http://www.portailsig.org/content/qgis-lancer-des-scripts-python-ou-des-commandes-shell-depuis-la-console-python-ou-avec-scrip
> http://www.portailsig.org/content/qgis-lancer-des-scripts-python-ou-des-commandes-shell-depuis-la-console-python-ou-avec-scrip
> , in French)
>
> When we try to use Arcpy in GRASS GIS or QGIS, the error message is
>  import sys
>  sys.path.append('C:\\Program Files\\ArcGIS\\Desktop10.0\\arcpy\\')
>  sys.path.append('C:\\Program Files\\ArcGIS\\Desktop10.0\\Bin\\')
>  import arcpy
>  Traceback (most recent call last):
> ....
>  *ImportError: Module use of python26.dll conflicts with this version of
> Python*.
>
> same thing if i use subprocess.Popen
>
> If i do the same thing in ArcPy
>    sys.path.append('C:\\Program Files\\GRASS
> 6.4.2\\Python27\\Lib\\site-packages')
>    import wx
>    Traceback (most recent call last):
>    ...
>    *ImportError: Module use of python27.dll conflicts with this version of
> Python*.
>
>
> so i do not think that the problem comes from the different versions of
> Python
>
>
>
>
> --
> View this message in context: http://osgeo-org.1560.n6.nabble.com/GRASS-ArcGIS-and-Python-incompatibilties-tp4984692p4984776.html
> Sent from the Grass - Users mailing list archive at Nabble.com.
> _______________________________________________
> grass-user mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/grass-user
_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Reply | Threaded
Open this post in threaded view
|

Re: GRASS, ArcGIS, and Python incompatibilties

Glynn Clements
In reply to this post by Michael Barton

Michael Barton wrote:

> I thought I'd seen this somewhere on the list, but I can't seem to find
> it. If there is a posted answer, perhaps someone could point me to it.
> Otherwise, hopefully, someone can offer an answer.
>
> I'm working with a colleague who has Windows 7 and ArcGIS installed. He
> installed GRASS for Windows, but it won't launch due to some combination
> of Python/wxPython incompatibility. We're pretty sure that it has to do
> with the version of Python he had to install with ArcGIS. The ArcGIS
> Python is 2.6, but GRASS for Windows comes with Python 2.7. Is there
> some configuration setting to get around this?

GRASS 7 should be able to use any of 2.5, 2.6, or 2.7. The Windows
installer tries to force the use of a bundled version, so you may need
to undo that first (remove it's bundled Python, unset any PYTHONHOME
or PYTHONPATH variables, etc).

--
Glynn Clements <[hidden email]>
_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Reply | Threaded
Open this post in threaded view
|

Re: GRASS, ArcGIS, and Python incompatibilties

gene
Glynn Clements wrote
remove it's bundled Python, unset any PYTHONHOME or PYTHONPATH variables, etc).
I repeat, I think this is not the problem. We are running QGIS 1.7.4, 1.8, GRASS GIS 6.2.4 and 7 dev, ArcGIS 10 and standard Python 2.5 without problem (Windows XP)

Each version of Python (2.5,2.6 and 2.7) works independently without problem .
Reply | Threaded
Open this post in threaded view
|

Re: GRASS, ArcGIS, and Python incompatibilties

Michael Barton
In reply to this post by Glynn Clements
Don't you need to have the wxPython that GRASS was compiled with? And doesn't this wxPython have to match the Python version?

Michael

On Jun 29, 2012, at 1:49 PM, Glynn Clements wrote:

>
> Michael Barton wrote:
>
>> I thought I'd seen this somewhere on the list, but I can't seem to find
>> it. If there is a posted answer, perhaps someone could point me to it.
>> Otherwise, hopefully, someone can offer an answer.
>>
>> I'm working with a colleague who has Windows 7 and ArcGIS installed. He
>> installed GRASS for Windows, but it won't launch due to some combination
>> of Python/wxPython incompatibility. We're pretty sure that it has to do
>> with the version of Python he had to install with ArcGIS. The ArcGIS
>> Python is 2.6, but GRASS for Windows comes with Python 2.7. Is there
>> some configuration setting to get around this?
>
> GRASS 7 should be able to use any of 2.5, 2.6, or 2.7. The Windows
> installer tries to force the use of a bundled version, so you may need
> to undo that first (remove it's bundled Python, unset any PYTHONHOME
> or PYTHONPATH variables, etc).
>
> --
> Glynn Clements <[hidden email]>

_____________________
C. Michael Barton
Visiting Scientist, Integrated Science Program
National Center for Atmospheric Research &
University Consortium for Atmospheric Research
303-497-2889 (voice)

Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu





_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Reply | Threaded
Open this post in threaded view
|

Re: GRASS, ArcGIS, and Python incompatibilties

Michael Barton
In reply to this post by Michael Barton
Yes. That's great it is working for you. But in our case, it won't launch the wxPython GUI and generates a Python error that it cannot find the correct version of Python. This is the stock version of GRASS that works for you and others (so Python is OK there) and Python works fine in ArcGIS, so it is OK there. So the signs point strongly to some kind of path/python path issue.

Michael


On Jun 30, 2012, at 1:00 PM, <[hidden email]>
 wrote:

From: gene <[hidden email]>
Subject: Re: [GRASS-user] GRASS, ArcGIS, and Python incompatibilties
Date: June 29, 2012 3:40:28 PM MDT



Glynn Clements wrote

remove it's bundled Python, unset any PYTHONHOME or PYTHONPATH variables,
etc).


I repeat, I think this is not the problem. We are running QGIS 1.7.4, 1.8,
GRASS GIS 6.2.4 and 7 dev, ArcGIS 10 and standard Python 2.5 without problem
(Windows XP)

Each version of Python (2.5,2.6 and 2.7) works independently without problem
.

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/GRASS-ArcGIS-and-Python-incompatibilties-tp4984692p4984993.html
Sent from the Grass - Users mailing list archive at Nabble.com.


_____________________
C. Michael Barton
Visiting Scientist, Integrated Science Program
National Center for Atmospheric Research &
University Consortium for Atmospheric Research
303-497-2889 (voice)

Director, Center for Social Dynamics & Complexity 
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University






_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Reply | Threaded
Open this post in threaded view
|

Re: GRASS, ArcGIS, and Python incompatibilties

gene
What versions of Python are in the registry database ?
What is the error message ? (detail of the version mismatch)

You can compare the paths used by the Python versions in ArcGIS (from the Python console) and in GRASS GIS (from the msys shell)

>>> import sys
>>> print sys.path

Normally the result should be different. If they are some same elements, look if there are PYTHONHOME or PYTHONPATH variables defined in the PATH variable or in the registry database as Glynn Clements wrote. How Windows defines these variables is a bit complex...


Reply | Threaded
Open this post in threaded view
|

Re: GRASS, ArcGIS, and Python incompatibilties

Glynn Clements
In reply to this post by Michael Barton

Michael Barton wrote:

> Don't you need to have the wxPython that GRASS was compiled with?
> And doesn't this wxPython have to match the Python version?

GRASS isn't "compiled" with any version of Python, i.e. it doesn't
have any binaries which link against the Python DLL/DSO.

At one time there were binary modules for the wx GUI's nviz and vdigit
components, and the SWIG wrappers, but those have all since been
eliminated.

--
Glynn Clements <[hidden email]>
_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Reply | Threaded
Open this post in threaded view
|

Re: GRASS, ArcGIS, and Python incompatibilties

Michael Barton
Does this mean that we no longer *have* to bundle wxPython with the Mac binaries? That they will work with whatever wxPython is installed (assuming it is within the range of supported versions, of course) regardless of what it was compiled with?

Michael

On Jun 30, 2012, at 4:32 PM, Glynn Clements wrote:

>
> Michael Barton wrote:
>
>> Don't you need to have the wxPython that GRASS was compiled with?
>> And doesn't this wxPython have to match the Python version?
>
> GRASS isn't "compiled" with any version of Python, i.e. it doesn't
> have any binaries which link against the Python DLL/DSO.
>
> At one time there were binary modules for the wx GUI's nviz and vdigit
> components, and the SWIG wrappers, but those have all since been
> eliminated.
>
> --
> Glynn Clements <[hidden email]>

_____________________
C. Michael Barton
Visiting Scientist, Integrated Science Program
National Center for Atmospheric Research &
University Consortium for Atmospheric Research
303-497-2889 (voice)

Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu





_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Reply | Threaded
Open this post in threaded view
|

Re: GRASS, ArcGIS, and Python incompatibilties

gene
Michael Barton wrote
Does this mean that we no longer *have* to bundle wxPython with the Mac binaries? That they will work with whatever wxPython is installed (assuming it is within the range of supported versions, of course) regardless of what it was compiled with?
it would be easy but no, because wxPython is not a pure Python library (only with Python files). It use wxWidgets (C++ library)

Be sure to use the same version of Python to run the script that you would like to use the wxPython binaries with
from http://wxpython.org/builddoc.php

The Mac OS X version, for example, is only available in 32-bit mode because  WxWidgets probably uses Carbon library, which is not available in  64-bit mode. "This, in turn, means that using it in Python requires you to launch Python in 32-bit mode (Python is a universal binary with both 32-bit and 64-bit versions of itself available in the same binary file, so it can be launched in either mode) from http://stackoverflow.com/questions/2565201/wxpython-incompatible-with-snow-leopard)

If you look at the downloads of the binaries of wxPython, there are also versions for Windows 32bits, and Windows 64bits for example
see also http://wiki.wxpython.org/TentativeRoadmap
It may be that the problem, but if we don't know the error message...  


Reply | Threaded
Open this post in threaded view
|

Re: GRASS, ArcGIS, and Python incompatibilties

Glynn Clements
In reply to this post by Michael Barton

Michael Barton wrote:

> Does this mean that we no longer *have* to bundle wxPython with the
> Mac binaries? That they will work with whatever wxPython is installed
> (assuming it is within the range of supported versions, of course)
> regardless of what it was compiled with?

That should be the case.

GRASS should only require that you have a suitable version of Python
with suitable versions of the necessary modules (primarily wxPython
and NumPy).

One issue with unbundling is that installing the additional components
may be considered inconvenient on platforms which lack package
management facilities.

OTOH, bundling has issues of its own, mainly that you may get
conflicts between the bundled version and the "system" version.

--
Glynn Clements <[hidden email]>
_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Reply | Threaded
Open this post in threaded view
|

Re: GRASS, ArcGIS, and Python incompatibilties

Michael Barton
In reply to this post by Michael Barton
See below to the solution to the problem of Python incompatibilities with ArcGIS and/or other Pythons

Many thanks to all who offered insight into this issue.

Michael

Begin forwarded message:

From: Kevin Sampson <[hidden email]>
Date: July 2, 2012 4:42:31 PM MDT
To: Michael Barton <[hidden email]>
Subject: Re: grass-user Digest, Vol 75, Issue 2

Michael,

I traced the problem down and fixed it.  It was simple enough, but certainly did have to do with there being another version of python installed on my system (the ArcGIS installation).  I simply:

1. Changed the GISBASE environment variable to the new Grass Installation directory (it had previously been set to an old installation that i had already uninstalled).

2. Changed the Init.bat file in %GISBASE%\etc so that %PYTHONPATH% (which was present because of my ArcGIS python instlalation) was no longer part of the PYTHONPATH variable at GRASS startup.

before:
set PYTHONPATH=%PYTHONPATH%;%GISBASE%\etc\python;%GISBASE%\etc\wxpython

after:
set PYTHONPATH=%GISBASE%\etc\python;%GISBASE%\etc\wxpython


Cheers,

Kevin
Kevin Sampson
Associate Scientist
National Center for Atmospheric Research
P.O. Box 3000 Boulder, CO  80307-3000
Tel: 303.497.8121           Fax: 303.497.8125
E-mail: [hidden email]   Web: www.gis.ucar.edu


_____________________
C. Michael Barton
Visiting Scientist, Integrated Science Program
National Center for Atmospheric Research &
University Corporation for Atmospheric Research
303-497-2889 (voice)

Director, Center for Social Dynamics & Complexity 
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University


_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Reply | Threaded
Open this post in threaded view
|

Re: GRASS, ArcGIS, and Python incompatibilties

Glynn Clements

Michael Barton wrote:

> > 2. Changed the Init.bat file in %GISBASE%\etc so that %PYTHONPATH%
> > (which was present because of my ArcGIS python instlalation) was no
> > longer part of the PYTHONPATH variable at GRASS startup.
> >
> > before:
> > set PYTHONPATH=%PYTHONPATH%;%GISBASE%\etc\python;%GISBASE%\etc\wxpython
> >
> > after:
> > set PYTHONPATH=%GISBASE%\etc\python;%GISBASE%\etc\wxpython

If the Windows installer is bundling Python, this change is correct.
If PYTHONPATH is already set prior to starting GRASS, there's no
reason to believe that the directories to which it refers contain
packages which are compatible with the bundled Python.

--
Glynn Clements <[hidden email]>
_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user
Reply | Threaded
Open this post in threaded view
|

Re: GRASS, ArcGIS, and Python incompatibilties

Michael Barton
It is bundling Python.

Michael

On Jul 2, 2012, at 7:54 PM, Glynn Clements wrote:

>
> Michael Barton wrote:
>
>>> 2. Changed the Init.bat file in %GISBASE%\etc so that %PYTHONPATH%
>>> (which was present because of my ArcGIS python instlalation) was no
>>> longer part of the PYTHONPATH variable at GRASS startup.
>>>
>>> before:
>>> set PYTHONPATH=%PYTHONPATH%;%GISBASE%\etc\python;%GISBASE%\etc\wxpython
>>>
>>> after:
>>> set PYTHONPATH=%GISBASE%\etc\python;%GISBASE%\etc\wxpython
>
> If the Windows installer is bundling Python, this change is correct.
> If PYTHONPATH is already set prior to starting GRASS, there's no
> reason to believe that the directories to which it refers contain
> packages which are compatible with the bundled Python.
>
> --
> Glynn Clements <[hidden email]>

_____________________
C. Michael Barton
Visiting Scientist, Integrated Science Program
National Center for Atmospheric Research &
University Consortium for Atmospheric Research
303-497-2889 (voice)

Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu





_______________________________________________
grass-user mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/grass-user