What's the bad magic number error?

后端 未结 15 2362
心在旅途
心在旅途 2020-11-22 16:56

What\'s the \"Bad magic number\" ImportError in python, and how do I fix it?

The only thing I can find online suggests this is caused by compiling a .py -> .pyc file

15条回答
  •  旧巷少年郎
    2020-11-22 17:54

    You will need to run this command in every path you have in your environment.

    >>> import sys
    >>> sys.path
    ['', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/usr/local/lib/python3.6/dist-packages', '/source_code/src/python', '/usr/lib/python3/dist-packages']
    
    

    Then run the command in every directory here

    find /usr/lib/python3.6/ -name "*.pyc" -delete
    find /usr/local/lib/python3.6/dist-packages -name "*.pyc" -delete
    # etc...
    

提交回复
热议问题