How to set the compiler to python2.7 that comes with arcgis in spyder

@[TOC]How to set the compiler to python2.7 that comes with arcgis in spyder

1. Current problems

To apply the downloaded python in spyder, you need to install the spyder_kernels package. But the python2.7 that comes with my arcgis seems to be unable to use pip to download and install. I searched on the Internet, and it should be that setuptools and pip are not installed. So we have to install these first.

2. Install setuptools and easy_install and pip

Here I refer to another blogger's blog ( ARCGIS python2.7.8 (32-bit, 64-bit) install pip easy_install setuptools ). Let me briefly introduce it here.

1. Download the latest version of 2019 (setuptools) and link the latest version of 2019 (setuptools)

1.1. Unzip the compressed package (setuptools-42.0.2.zip) and put it on the desktop (or other places, I put it here for the convenience of introduction and description, and I suggest you put it here).
1.2. Open the cmd window (right-click Start-Run-enter "cmd" and confirm), enter the setuptools-42.0.2 folder (the command is cd C:\Users\chenlongfei\Desktop\setuptools-42.0.2).
insert image description here

1.3. Continue to enter py -2 setup.py install. **Note that it is best to use py -2 here instead of python setup.py install, because I also have python3.8 version installed in my computer, directly enter python setup.py install and it will be installed into version 3.8. **Wait for its installation to complete.
insert image description here

2. Download the latest version of 2019 (pip) link to the latest version of 2019 (pip)

2.1. Also decompress the compressed package (pip-19.3.1.tar.gz) and put it on the desktop (or other places, I put it here for the convenience of introduction and description, and I suggest you put it here).
2.2. Open the cmd window (right-click Start-Run-enter "cmd" and confirm), enter the setuptools-42.0.2 folder (the command is cd C:\Users\chenlongfei\Desktop\pip-19.3.1).
insert image description here
2.3. Continue to enter py -2 setup.py install. Wait for its installation to complete.

insert image description here
2.4. After completion. Enter pip2 in cmd. ( Note that it is best to use pip2 here instead of pip, because I also have python3.8 version installed in my computer, and the version 3.8 is displayed when I directly enter pip. ). As shown in the figure below, even if pip is successfully installed. You can use pip to download other packages.
insert image description here

3. Set the compiler in spyder to python2.7 that comes with arcgis

Here you can refer to my other blog: When Anaconda changes the python compiler, An error occurred while starting the kernel is displayed . Here I will briefly introduce again.
3.1 Enter pip2 install spyder_kernels in the cmd interface. Just wait for the installation to complete.
3.2 After installation, click Tools–preference–python interpreter in spyder and change Default to Use the following python interpreter. Find python.exe again, and click OK. As shown in the picture below, mine is under the path of D:\arcgis10.5\Python2.7\ArcGIS10.5\python.exe.
insert image description here
3.3 After selecting and confirming, you also need to click Consoles–Restart kernals, and the interface for entering the command line appears to indicate success. Let's try import arcpy again. If it can be imported, it is successful.
insert image description here

Guess you like

Origin blog.csdn.net/weixin_42999968/article/details/112097207