[英]Python Arcpy: Non-ASCII character in library import
I was debugging a basic GIS python script, when I randomly(?) got this error: 当我随机(?)收到此错误时,我正在调试基本的GIS python脚本:
Traceback (most recent call last):
File "<module1>", line 13, in <module>
import arcpy
File "C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\__init__.py", line 25, in <module>
from arcpy.toolbox import *
File "C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\toolbox.py", line 371, in <module>
from .management import Graph, GraphTemplate
File "C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\management.py", line 5694
SyntaxError: Non-ASCII character '\xc2' in file C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\management.py on line 5695, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
Tried just running import arcpy
and the same error popped up. 尝试仅运行import arcpy
并弹出相同的错误。 So far here's what I tried: 到目前为止,这是我尝试的操作:
I'm stumped. 我很沮丧 Yes, I could reinstall the library, but that's quite involved as this library is a tiny part of a massive software package. 是的,我可以重新安装该库,但这相当复杂,因为该库只是大型软件包的一小部分。
您可以尝试在第一行中添加“ #encoding:utf-8”
Add # -*- coding: utf-8 -*-
at the top of your script. 在脚本顶部添加# -*- coding: utf-8 -*-
。
Probably the IDE that you are using, use the default encoding set. 可能您正在使用的IDE使用默认的编码集。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.