Why Python 3.6.1 throws AttributeError: module 'enum' has no attribute 'IntFlag'?

前端 未结 17 1079
无人共我
无人共我 2020-11-22 16:34

I just installed Python 3.6.1 for MacOS X

When I attempt to run the Console(or run anything with Python3), this error is thrown:

  AttributeError: mo         


        
17条回答
  •  感情败类
    2020-11-22 17:04

    I had this problem in ubuntu20.04 in jupyterlab in my virtual env kernel with python3.8 and tensorflow 2.2.0. Error message was

     Traceback (most recent call last):
      File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
        "__main__", fname, loader, pkg_name)
      File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
        exec code in run_globals
      File "/home/hu-mka/.local/lib/python2.7/site-packages/ipykernel_launcher.py", line 15, in 
        from ipykernel import kernelapp as app
      File "/home/hu-mka/.local/lib/python2.7/site-packages/ipykernel/__init__.py", line 2, in 
        from .connect import *
      File "/home/hu-mka/.local/lib/python2.7/site-packages/ipykernel/connect.py", line 13, in 
        from IPython.core.profiledir import ProfileDir
      File "/home/hu-mka/.local/lib/python2.7/site-packages/IPython/__init__.py", line 48, in 
        from .core.application import Application
      File "/home/hu-mka/.local/lib/python2.7/site-packages/IPython/core/application.py", line 23, in 
        from traitlets.config.application import Application, catch_config_error
      File "/home/hu-mka/.local/lib/python2.7/site-packages/traitlets/__init__.py", line 1, in 
        from .traitlets import *
      File "/home/hu-mka/.local/lib/python2.7/site-packages/traitlets/traitlets.py", line 49, in 
        import enum
    ImportError: No module named enum
    

    problem was that in symbolic link in /usr/bin/python was pointing to python2. Solution:

    cd /usr/bin/
    sudo ln -sf python3 python
    

    Hopefully Python 2 usage will drop off completely soon.

提交回复
热议问题