1

I'm running Python 3.4.3 on Ubuntu 15.04 and just encountered a very strange problem when trying to use the input() function.

To isolate the problem Iv'e created a file called test.py contaning:

print(input())

When running it, I receive this error:

$ python3 test.py
Fatal Python error: Py_Initialize: can't initialize sys standard streams
ImportError: bad magic number in 'io': b'\x03\xf3\r\n'
[1]    8599 abort (core dumped)  python3 test.py

Does anyone know what's going on?

1

1 Answer 1

1

Magic number is the term for the first two bytes of an executable file. It is used to determine how the executable should be loaded.

The magic number is also used in *.pyc files that are compiled from the *.py files. It says what version of bytecode is used inside.

In your case, it seems that you have newer Python now, and there are some *.pyc files from the old version. This should have been solved during installation, but it probably was not.

Just search for the *.pyc files and remove them. They will be created automatically.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.