What's the bad magic number error?

后端 未结 15 2321
心在旅途
心在旅途 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:57

    In my case, I've git clone a lib which had an interpreter of

    #!/usr/bin/env python
    

    While python was leading to Python2.7 even though my main code was running with python3.6 ... it still created a *.pyc file for 2.7 version ...

    I can say that this error probably is a result of a mix between 2.7 & 3+ versions, this is why cleanup ( in any way you can think of that you're using ) - will help here ...

    • don't forget to adjust those Python2x code -> python 3...

提交回复
热议问题