I ran across this slight issue when I was looking to access python installations from ArcGIS, QGIS, Anaconda (cited because SciPy & NumPy come with it), and version 2.7 vs 3. Sometimes, I find it easier to just pop into Windows' Command Prompt
to do a little bit of quick work instead of opening up a GIS program or python IDE in order to access the interactive prompt.
Instead of navigating to each folder, setting shortcuts, or switching out the PATH
environment variable, I wanted a different way to access each python installation via the Command Prompt
.
Edit
GIS professionals who use python for their work end up having to access each installation manually in order to access the features held within. Instead of waiting on something like ArcMap to load, it is generally much quicker to hit your winkey-r + cmd and type python
into your Command Prompt to start up the python console. If you want to use ArcPy
to reproject a shapefile, you need to open your python console, which is linked to ArcPy
. If you want to use a tool from PyQGIS
because you don't have the appropriate ESRI license, you need to find the python.exe
that is linked to those modules. This can be a pain when you're trying to do work in ArcPy
, PyQGIS
, NumPy
, or SciPy
without having all the libraries installed cohesively as one python installation.
Typically, you're bound by your Path
variable to which python installation is your default while in the Command Prompt
. This question and the answers following look to address how GIS professionals might be able to utilize multiple python installations together in a single environment. Python IDEs target a single python installtion and require changing settings in order to utilize different ones. For instance, my PyScripter
install targets my ArcGIS installation of Python. So, if I want to utilize my PyQGIS
modules, I need to open up QGIS or change the settings in PyScripter
.
When writing modules/full scripts, it makes sense to target one individually. That way you might get some sort of code completion happening. However, when you're just utilizing some tools in each installation to manipulate a data set, it would be much nicer if you can quickly flip python consoles/installations within a single screen aka the Command Prompt
.
Although this obviously applies to anything the python language is attached to, for the poor GIS user who can't afford to buy ESRI extensions for data analysis tools, it serves as a way for them to simplify their life. As some of the answers have shown, being able to customize this process more, e.g. add arguments to .cmd
files, could potentially be of great use if someone is running a custom process. There is potential for a more savvy GIS/computer user to be able to set up custom .cmd
files to quickly run processes without having to go through the fuss of dealing with different IDEs/GIS software installs etc..
The only downside to running a python console within the Command Prompt
is the loss of code completion. However, if you run something enough, such as arcpy.AddField_management()
, the code completion just gets in the way.
No comments:
Post a Comment