Python3安装motionless-1.1后报错的修正

在Python3中安装motionless1.1后,运行

import motionless

系统报错:

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    import motionless
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2222, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 2164, in _find_spec
  File "<frozen importlib._bootstrap>", line 1940, in find_spec
  File "<frozen importlib._bootstrap>", line 1916, in _get_spec
  File "<frozen importlib._bootstrap>", line 1897, in _legacy_get_spec
  File "<frozen importlib._bootstrap>", line 863, in spec_from_loader
  File "<frozen importlib._bootstrap>", 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




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值