Import Error: No module called magic yet python-magic is installed
<p>I am trying to edit some code that uses python-magic but I get an <em>Import Error: No module called magic</em>. Before I looked around the Internet and found advise on installing python-magic using pip which I did. I installed  python-magic using pip install python-magic and also did pip install libarchive-c successfully.</p>

<p>when I try to do the import on the python shell. I am able to successfully as below;
<a href="https://i.stack.imgur.com/iWvmm.png" rel="nofollow"><img src="https://i.stack.imgur.com/iWvmm.png" alt="sc1"></a></p>

<p>But when I try to run code that uses this import statement I get an import error for missing magic module as below;
<a href="https://i.stack.imgur.com/jOCkB.png" rel="nofollow"><img src="https://i.stack.imgur.com/jOCkB.png" alt="sc2"></a></p>

<p>If anyone knows what is happening. Please help.</p>

<p>You have installed <code>magic</code> for Python 2.7, but Diffoscope uses Python 3 and <a href="http://pydigger.com/pypi/diffoscope" rel="nofollow">explicitly recommends</a> the package <a href="http://packages.ubuntu.com/search?keywords=python3-magic" rel="nofollow"><code>python3-magic</code></a> in the repositories, which can be installed with <code>sudo apt-get install python3-magic</code>. Modules installed for Python 2.7 are not necessarily shared with Python 3, so you may need to install both versions if you need it for 2.7 as well.</p>

<p>On Ubuntu, you can run Python 3 with <code>python3</code> and access Python 3's pip installation with <code>pip3</code> to ensure that you are using the correct version.</p>

python python-magic