python3错误 module 'enum' has no attribute 'IntFlag'

在全新的环境中安装jupyter时出现错误:AttributeError: module 'enum' has no attribute 'IntFlag',错误详情如下

==> script messages <==
Traceback (most recent call last):
  File "/home/path/to/miniconda2/envs/py3/bin/jupyter-nbextension", line 4, in <module>
    import re
  File "/home/path/to/miniconda2/envs/py3/lib/python3.7/re.py", line 143, in <module>
    class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'

同理,直接import re时也会出现同样错误,查询发现,是PYTHONPATH的设置错误,在.bashrc中存留有以前使用python2时留下的配置,导致python3不能找到正确的enum位置,注释掉bashrc中相关语句后,清空$PYTHONPATH变量即可:

 unset PYTHONPATH
 #查看是否清空
 echo $PYTHONPATH

然后即可正常使用,PYTHONPATH是python2中多用的配置,使用python3和conda后一般不再需要

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值