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
- Python 3.4 compiler prompt error: unexpected indent
- [shell] sh executes the script and reports an error syntax error: “(” unexpected “)
- Hadoop reports an error. Cannot access scala.serializable and python MapReduce reports an error
- Set code indent to space indent in eclipse
- The remote port occupation of Linux startup jar package script reports an error
- Vue project reports an error on ie11 white screen. Script1002: syntax error
- The build report plug-in reported an error in importing unit script (BRT_ Util.cs :error CS1525: Unexpected symbol `;’, expecting `)’, or `,’）
- Vue executes NPM run Dev and reports an error: missing script: dev
- PHP reports “parse error: syntax error, unexpected T”_ The solution of “variable”
- Python calls DLL and reports an error windowserror: [error 126]
- QT + MySQL generates an EXE file and reports an error “driver not loaded”. Solution steps
- [development experience] solution to unexpected syntax error: unexpected identifier in JSON parsing
- Solve the problem of shell script “syntax error near unexpected token `fi’”.
- Jedis reports errors using tool classes
- The sharepoint2010 site cannot open a solution that displays an “an unexpected error has occurred” error
- python got an unexpected keyword argument
- Syntax error near unexpected token `newline’script cannot be executed
- NPM installs dependent packages and reports an error node gyp rebuild… Solution
- Python calls C to generate so library and reports an error: undefined symbol
- Vue console reports an error duplicate keys detected: ‘XXXX’. This may cause an update error. Solution