在Python3中安装motionless1.1后,运行
import motionless
系统报错:
Traceback (most recent call last):
File "", line 1, in
import motionless
File "", line 2237, in _find_and_load
File "", line 2222, in _find_and_load_unlocked
File "", line 2164, in _find_spec
File "", line 1940, in find_spec
File "", line 1916, in _get_spec
File "", line 1897, in _legacy_get_spec
File "", line 863, in spec_from_loader
File "", line 904, in spec_from_file_location
File "C:\Python34\lib\site-packages\motionless-1.1-py3.4.egg\motionless.py", line 55
if label and (len(label) <> 1 or not label in Marker.LABELS):
^
SyntaxError: invalid syntax
原因是motionless的版本虽然为motionless-1.1-py3.4,但其中很多语法仍然没有更新。
修正方法:
从C:\Python34\Lib\site-packages中找到motionless-1.1-py3.4.egg,用解压缩软件打开,找到其中的motionless.py,再用编辑软件或记事本打开,修改以下几行:
1、第1行 quote,改为parse
from urllib import parse
2、第55行和第190行中的<>改为!=
if label and (len(label) != 1 or not label in Marker.LABELS):
if self.region and self.path[0] != self.path[-1]:
3、调整第178、179、196行的缩进,与前文保持8个空格(英文模式下)
self.markers = []
self.fillcolor = fillcolor
self.pathweight = pathweight
self.pathcolor = pathcolor
self.region = region
self.path = []
if self.region and self.path[0] != self.path[-1]:
raise ValueError("If region enabled, first and last path entry must be identical")
if len(self.path) == 0 and len(self.markers) == 0:
raise ValueError("Must specify points in path or markers")
if not Color.is_valid_color(self.fillcolor):
raise ValueError("%s is not a valid fill color. Must be 24 or 32 bit value or one of %s" % (self.fillcolor,Color.COLORS))
4、文中所有的quote更正为parse.quote