Oct-21-2018, 02:11 PM
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/t...n-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
main_program.py
I am following a tutorial topic 'How To Import Modules in Python 3' at https://www.digitalocean.com/community/t...n-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.
Error:Traceback (most recent call last):
File "main_program.py", line 2, in <module>
import hello
ImportError: bad magic number in 'hello': b'\x03\xf3\r\n'
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.