[split] Bad magic number. What is it ? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: [split] Bad magic number. What is it ? (/thread-13568.html) |
[split] Bad magic number. What is it ? - Douglas - Oct-21-2018 I have the same problem as Sylas has described although I am not interested what a bad magic number is unless the information leads to a solution. I am following a tutorial topic 'How To Import Modules in Python 3' at https://www.digitalocean.com/community/tutorials/how-to-write-modules-in-python-3 All went well until, following instructions, I moved the module file hello.py from the same directory as the file which imports the module, main_program.py, to one of the directories listed by print(sys.path), namely, /home/<myusername>/.local/lib/python3.5/site-packages/hello.py hello.py # Define a function def world(): print("Hello, World!") main_program.py # Import hello module import hello # Call function hello.world()This results in the same error message as reported my Sylas. I am running Python 3.6.5 (default, Sep 6 2018, 17:29:53) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux 3.10.0-862.3.2.el7.x86_64.
RE: [split] Bad magic number. What is it ? - buran - Oct-21-2018 https://stackoverflow.com/a/514395/4046632 RE: [split] Bad magic number. What is it ? - Douglas - Oct-22-2018 Thank you buran. As mentioned in https://stackoverflow.com/a/514395/4046632 there was a .pyc file in the calling program's directory and deleting it fixed the 'ImportError: bad magic number' error. |