ArcGIS 10.2.2 comes with Python 2.7.5 install pip, and configure gdal and arcpy (20200929)
premise
ArcGIS 10.2.2 has been installed (with Python 2.7.5)
Add environment variables to Path for Python (set to D:\Python 2.7\ArcGIS10.2)
Install pip for Python 2.7.5 that comes with ArcGIS
Because Python2 does not come with pip like Python3, in order to install pip for ArcGIS's own Python, two steps are required: the first step is to install setuptools; the second step is to install pip .
1. First go to the official website of setuptools: https://pypi.org/project/setuptools/42.0.2/ . Check whether the version supports Python2.7, then download the setuptools-42.0.2.zip and unzip it to the Python2.7.5 directory.
Then in the D:\Python 2.7\ArcGIS10.2\setuptools-42.0.2 directory, hold down shift and right-click to open the cmd command line window, enter the following:
python setup.py install
The result after setuptools is installed:
2. First go to the pip official website: https://pypi.org/project/pip/19.3.1/ . Check whether the version supports Python2.7, and then you need to download the file pip-19.3 required for pip installation .1.tar.gz (the version used here is 19.3.1 ), the decompressed folder pip-19.3.1 is placed here in the Python2.7.5 directory. Then in the Python 2.7.5 directory, hold down shift and right-click to open the cmd window, enter the following:
python setup.py install
Then there will be pip.exe program in the D:\Python 2.7\ArcGIS10.2\Scripts directory.
Pip install gdal in python environment
Open the link of Unofficial Windows Binaries for Python Extension Packages: https://www.lfd.uci.edu/~gohlke/pythonlibs/ .
Use Ctrl+F to find GDAL, and then find the whl file corresponding to the python version, here we will GDAL Download the -2.2.4-cp27-cp27m-win32.whl file and place it in the D:\Python 2.7\ArcGIS10.2\Scripts directory, then hold down shift in this directory and click the right mouse button to open the cmd command line window , Enter the following in the command line:
pip install GDAL-2.2.4-cp27-cp27m-win32.whl
The result after running is shown in the figure below, gdal is installed successfully;
View all libraries installed by Python 2.7.5
You can go to the file directory D:\Python 2.7\ArcGIS10.2\Lib\site-packages to view the packages we have installed
Python import arcpy problem solving
In the D:\Python 2.7\ArcGIS10.2\Lib\site-packages directory, open desktop10.2.pth to view the directory corresponding to ArcGIS Desktop.
Method 1: Add the environment variable PYTHONPATH, set it to directly create a new "PYTHONPATH" in the environment variable and add three directories corresponding to ArcGIS Desktop to
D:\ArcGIS 10.2.2\Desktop10.2\bin
D:\ArcGIS 10.2 .2\Desktop10.2\arcpy
D:\ArcGIS 10.2.2\Desktop10.2\ArcToolbox\Scripts
Method 2: Install pywin32 in pip mode (using the pywin32-228-cp27-cp27m-win32.whl file), first download the files required by pywin32 (note that it corresponds to the Python version): https://pypi.org/project/pywin32/ #files ., download the pywin32-228-cp27-cp27m-win32.whl file and store it in the D:\Python 2.7\ArcGIS10.2\Scripts directory, also in this directory, hold down shift and click the right mouse button to open the cmd command line Window, input
pip install pywin32-228-cp27-cp27m-win32.whl
After the installation is successful, go to the python installation directory (which comes with GIS). Generally, find the file with the suffix "pywin32.pth" in D:\Python 2.7\ArcGIS10.2\Lib\site-packages. This file is used for When telling python to import the package, you can also search the path from here, and add the three directories corresponding to ArcGIS Desktop to the end.
PyCharm instance running (check whether the arcpy and gdal libraries can be called)
Install P with Charm, create a new project, select ArcGIS Python 2.7.5 as the Python compiler, and then create a new Python file in the project, enter the content, and you can view