Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

As we know, there are few versions of Arcgis (9.x,10) and Python(2.x,3.x) are in use. Issues are facing when we run scripts/toolbox of arcgis since the script written in one version of python and the python installed with arcgis is different version.

Q1) How to identify python script version so that we can directly execute and save time? Q2) How to convert the existing python script to the installed python version on the system and get result without hassle of programing? Q3) Is there any procedure for arcgis to take python version 2/3.x as default so that, we can install multiple versions of python and change default version to run according to our requirement?

share|improve this question
    
What's the use case for having that many versions of Python installed on one system? Why don't you just support a single version? All Python scripts written for 9.3 will continue to work in 10.0 and 10.1, so a long as you develop against the lowest common denominator you should be fine. –  Jason Scheirer Mar 26 '12 at 0:19

2 Answers 2

up vote 4 down vote accepted

1) There's no such thing as a script version, but there is a standard for defining package requirements for a Python interpreter version. See PEP 345: http://www.python.org/dev/peps/pep-0345/.

2) Search for "2to3". It does not remove the "hassle" of programming.

3) In Python programming, we use virtualenv to juggle interpreters and specific sets of packages. I don't know if ArcGIS supports such virtual environments.

share|improve this answer

Every version of ArcGIS requires a specific Major.Minor version of Python (it uses the official installer releases from python.org). That version will be documented in the help. 9.3.X uses Python 2.5, 10.0 uses 2.6, 10.1 uses 2.7. Since the stack is compiled against a specific binary version of Python, other versions of Python will fail to load arcgisscripting and nothing will work.

You can use sys.version_info tuple to determine the Python version at runtime.

share|improve this answer
2  
e.g., use sys.version_info[:2] >= (2, 5) to test if it is Python 2.5 or later –  Mike T Mar 26 '12 at 4:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.