Can I install Python 3.3 on the computer with ArcGIS 9.3 and Python 2.5?

701
1
Jump to solution
09-02-2013 05:06 PM
NadyaBasos
New Contributor
I have ArcGIS 9.3 on Windows Vista 32. I want to study a Python course which requires Python 3.3. Can I install it using the official installer python-3.3.2.msi? Will something happen to ArcGIS? I have scripts for its Python 2.5, will I be able to run them?
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
StacyRendall1
Occasional Contributor III
You can have as many Python installs as you want, but it is important that you know some of the potential issues:

  1. I think you can only have one default system Python, that stuff gets installed to or pops up if you enter "python" at the command line. This means you have to know how to install libraries specifically to one or the other. See below. ArcGIS installs its Python behind the scenes, and does not make it the system default Python. I think the Python installer will make its one the default.

  2. Python 3 has a different syntax to Python 2, so scripts will not be directly transferable between them. The biggest difference is problably >>> print 'Hello world' (Python 2) vs >>> print('Hello world') (Python 3). If you were using Python 2.7 (installed by/works with ArcGIS 10.1) you can use the statement from __future__ import <package> to use <package> like Python 3. It is possible to convert scripts between Python 2 and 3, for example see here.

  3. The two Pythons will be separate. If you install a library, say Parallel Python, to your Python 3 it will not be accessible from your Python 2. If you write a script that requires the installed package (i.e. Parallel Python), and try to run it with the wrong Python, it will fail (ImportError). Importantly: Python 3 will not be able to access Arcpy, which is the ArcGIS library that lets you do geoprocessing from Python, as Arcpy is only compatible with Python 2 at the moment. Scripts that you write using Arcpy will fail (SyntaxError or ImportErrror) if you try to run them from Python 3.


Installing libraries to Non-default Python

To do this:

  1. download the package source (usually a .zip file, not specific to any Python version)

  2. Unzip the package

  3. Open a command prompt within the extracted package folder and run:

  4. [INDENT]python setup.py install
    [INDENT]where python is the Python you want to install the library to. If it is not on the path (either temporarily or permanently) you must supply the full path to it, i.e. c:\python27\ArcGIS10.1\python.exe[/INDENT][/INDENT]

Answers to your specific questions

I have ArcGIS 9.3 on Windows Vista 32. I want to study a Python course which requires Python 3.3. Can I install it using the official installer python-3.3.2.msi?

Yes.

Will something happen to ArcGIS?

No.

I have scripts for its Python 2.5, will I be able to run them?

Not directly; as described point 2 above, the syntax is different. The scripts can be converted, which will work fine as long as you have the same libraries installed to both Pythons; for example if you want to use Numpy it must be installed to Python 3 as well (it is installed to ArcGIS Python by default). Just remember that Python 3 scripts will not be able to access Arcpy.

You can even convert your Python 3 scripts back so you can use them in ArcGIS's Python 2, as long as you install any required libraries to it too...

View solution in original post

1 Reply
StacyRendall1
Occasional Contributor III
You can have as many Python installs as you want, but it is important that you know some of the potential issues:

  1. I think you can only have one default system Python, that stuff gets installed to or pops up if you enter "python" at the command line. This means you have to know how to install libraries specifically to one or the other. See below. ArcGIS installs its Python behind the scenes, and does not make it the system default Python. I think the Python installer will make its one the default.

  2. Python 3 has a different syntax to Python 2, so scripts will not be directly transferable between them. The biggest difference is problably >>> print 'Hello world' (Python 2) vs >>> print('Hello world') (Python 3). If you were using Python 2.7 (installed by/works with ArcGIS 10.1) you can use the statement from __future__ import <package> to use <package> like Python 3. It is possible to convert scripts between Python 2 and 3, for example see here.

  3. The two Pythons will be separate. If you install a library, say Parallel Python, to your Python 3 it will not be accessible from your Python 2. If you write a script that requires the installed package (i.e. Parallel Python), and try to run it with the wrong Python, it will fail (ImportError). Importantly: Python 3 will not be able to access Arcpy, which is the ArcGIS library that lets you do geoprocessing from Python, as Arcpy is only compatible with Python 2 at the moment. Scripts that you write using Arcpy will fail (SyntaxError or ImportErrror) if you try to run them from Python 3.


Installing libraries to Non-default Python

To do this:

  1. download the package source (usually a .zip file, not specific to any Python version)

  2. Unzip the package

  3. Open a command prompt within the extracted package folder and run:

  4. [INDENT]python setup.py install
    [INDENT]where python is the Python you want to install the library to. If it is not on the path (either temporarily or permanently) you must supply the full path to it, i.e. c:\python27\ArcGIS10.1\python.exe[/INDENT][/INDENT]

Answers to your specific questions

I have ArcGIS 9.3 on Windows Vista 32. I want to study a Python course which requires Python 3.3. Can I install it using the official installer python-3.3.2.msi?

Yes.

Will something happen to ArcGIS?

No.

I have scripts for its Python 2.5, will I be able to run them?

Not directly; as described point 2 above, the syntax is different. The scripts can be converted, which will work fine as long as you have the same libraries installed to both Pythons; for example if you want to use Numpy it must be installed to Python 3 as well (it is installed to ArcGIS Python by default). Just remember that Python 3 scripts will not be able to access Arcpy.

You can even convert your Python 3 scripts back so you can use them in ArcGIS's Python 2, as long as you install any required libraries to it too...