Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import Error: No module called magic yet python-magic is installed

I am trying to edit some code that uses python-magic but I get an Import Error: No module called magic. 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.

when I try to do the import on the python shell. I am able to successfully as below; sc1

But when I try to run code that uses this import statement I get an import error for missing magic module as below; sc2

If anyone knows what is happening. Please help.

like image 920
Joannah Nanjekye Avatar asked Oct 14 '16 17:10

Joannah Nanjekye


1 Answers

You have installed magic for Python 2.7, but Diffoscope uses Python 3 and explicitly recommends the package python3-magic in the repositories, which can be installed with sudo apt-get install python3-magic. 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.

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

like image 182
Aurora0001 Avatar answered Nov 13 '22 06:11

Aurora0001