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?

noamelf
  • 53
  • 2
  • 8
  • possible duplicate of [What's the bad magic number error?](http://stackoverflow.com/questions/514371/whats-the-bad-magic-number-error) – jfs Jun 18 '15 at 12:12

1 Answers1

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.

pepr
  • 20,112
  • 15
  • 76
  • 139