Can't import subprocess module into python3
<p>Im trying to import subprocess. However Im unable to even import subprocess.</p>

<p>Currently, my file (throwaway.py) consists of only one line:</p>

<pre><code>import subprocess
</code></pre>

<p>but it returns the error:</p>

<pre><code>Traceback (most recent call last):
  File "throwaway.py", line 1, in &lt;module&gt;
    import subprocess
ImportError: bad magic number in 'subprocess': b'\x03\xf3\r\n'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in &lt;module&gt;
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 12, in &lt;module&gt;
    import subprocess, tempfile, os.path, re, pwd, grp, os, time
ImportError: bad magic number in 'subprocess': b'\x03\xf3\r\n'

Original exception was:
Traceback (most recent call last):
  File "throwaway.py", line 1, in &lt;module&gt;
    import subprocess
ImportError: bad magic number in 'subprocess': b'\x03\xf3\r\n'
</code></pre>

<p>What are magic number errors? I read that they occur when you accidentally give a file the .pyc extention rather than .py? </p>

<p>Use <code>pyclean</code> and try to import it again. </p>

<pre><code>pyclean &lt;path&gt;
</code></pre>

<p>will remove all <code>pyc</code> files in path you'll provide (recursively), so there won't be compiled files, so no conflict.</p>

python subprocess