错误详情如下:
Traceback (most recent call last):
File "/usr/local/bin/evo_traj", line 5, in <module>
import re
File "/usr/lib/python3.6/re.py", line 142, in <module>
class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 62, in apport_excepthook
if not enabled():
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 24, in enabled
import re
File "/usr/lib/python3.6/re.py", line 142, in <module>
class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
Original exception was:
Traceback (most recent call last):
File "/usr/local/bin/evo_traj", line 5, in <module>
import re
File "/usr/lib/python3.6/re.py", line 142, in <module>
class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
问题分析
之前没出现过这个问题,怀疑是ubuntu系统更新后造成python迭代版本冲突,建议将ubuntu自动更新关闭,防止此类问题,有些版本冲突问题解决起来还是挺费时间的。
问题解决
查询发现,是PYTHONPATH的设置错误,在.bashrc中存留有以前使用python2时留下的配置,导致python3不能找到正确的enum位置,注释掉bashrc中相关语句后,清空$PYTHONPATH变量即可:
unset PYTHONPATH
#查看是否清空
echo $PYTHONPATH
然后即可正常使用,PYTHONPATH是python2中多用的配置,使用python3后一般不再需要。