At the beginning, I wrote an ArcGIS Python script, which is an independent script. I ran it in Python and ran it successfully. But if you put this script in the ArcGIS toolbox, it won’t work properly. The following errors are reported.
IndentationError: unexpected indent。
The above figure is an article from Baidu experience. Because there was no screenshot at that time, I didn’t bother to reproduce this problem again…
Code indentation problem
When searching for this error report on Baidu, most of the answers are to ask you to find the indentation problem and space problem in the code. As in the article from the above figure.
The problem is that my code can run successfully in pycharm, and I checked the code several times and found no problem…
Chinese in code (including Chinese in notes)
I use ArcGIS 10.2 and python version is 2.7. This version of Python doesn’t support Chinese very much, but generally you can run normally by adding # coding = UTF-8 at the beginning of the code in the python environment.
There is a Chinese comment on the last line of the wrong line of my code. So I tried to remove that line of Chinese notes and succeeded
1. If the python script of ArcGIS does not need Chinese, do not use Chinese
2. If you have to use Chinese, you can consider adding # coding: cp936 at the beginning of the script code
- Indenta in Python tionError:unindent does Error
- Package python3.1 + PyQt4 into exe
- Python 3.4 compiler prompt error: unexpected indent
- ArcGIS SOE unable to add extension FAQ
- Solution of Unicode decodeerror -‘utf-8 ‘codec can’t decode byte 0xc4 in position 0 – invalid continuation byte
- Python problem: indenta tionError:expected an Error resolution of indented block
- Pyinstaller packages the EXE file and executes the error unknown encoding: IDNA
- Importerror: DLL load failed while importing win32gui: 1 is not a valid Win32 Application.
- The registered version of ArcEngine can edit the data in SDE (How to Fix 0x80040356 Error)
- Idle line number setting and linenumbers modification
- Jetson nano uses Python to read and parse GPS data (GPRMC, gpgga).
- PIP report failed to create process
- Solution to the problem of Chinese garbled in gradle console in idea
- Running Python 3.7 web.py Runtimeerror: generator raised stopiteration exception occurred during test
- [ABAP] sproxy opens ESR and reports an error has occurred during communication ESR
- _ASSERTE((unsigned)(c + 1) <= 256);
- Run Python file for the first time with eclipse / pydev: “UTF-8 ‘codec can’t decode byte 0xc4 in position
- ArcGIS desktop experience. Similar to: error 000732 output Geodatabase
- To change the theme and font of your pychar
- Solution to Spacy’s failure to load (‘de ‘) or (‘en’)