What's the bad magic number error?

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

    In my case it was not .pyc but old binary .mo translation files after I renamed my own module, so inside this module folder I had to run

    find . -name \*.po -execdir sh -c 'msgfmt "$0" -o `basename $0 .po`.mo' '{}' \;
    

    (please do backup and try to fix .pyc files first)

提交回复
热议问题