我正在尝试在Colab中安装python-magic。这是库https://github.com/ahupp/python-magic#dependencies
的Github当我尝试时:
!pip install python-magic
import magic
这将导致
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-44-1461204615fc> in <module>()
1 get_ipython().system('pip install python-magic')
----> 2 import magic
/usr/local/lib/python3.6/dist-packages/magic.py in <module>()
179 if not libmagic or not libmagic._name:
180 # It is better to raise an ImportError since we are importing magic module
--> 181 raise ImportError('failed to find libmagic. Check your installation')
182
183 magic_t = ctypes.c_void_p
ImportError: failed to find libmagic. Check your installation
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
我尝试了所有可能的解决方案
这则SO帖子说 Exception Value:failed to find libmagic. Check your installation in windows 7
您的multiuploader表单可能使用python-magic库进行文件类型识别。但是,您可能没有安装所有缺少的依赖项。请安装缺少的依赖项。 https://github.com/ahupp/python-magic#dependencies
但是不再列出依赖项。
我也尝试过
pip install python_magic_bin-0.4.14-py2.py3-none-win_amd64.whl
和
pip install python_magic_bin-0.4.14-py2.py3-none-win32.whl
此SO帖子
pip installing eyeD3 module. Failed to find libmagic
我尝试了
pip install python-magic-bin==0.4.14
我也尝试过
!brew install libmagic
但是Colab似乎无法识别brew
答案 0 :(得分:2)
在Colab上安装Libmagic的方法如下:
!apt-get install libmagic-dev
!pip install python-magic
然后,您可以毫无问题地导入它:
import magic