我正在尝试在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.
---------------------------------------------------------------------------
我已经尝试了所有可能的解决方案
这个帖子说异常值:找不到库魔法。检查您在 Windows 7 中的安装
您的多重上传表单使用 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帖子
点安装眼D3模块。找不到libmagic。
我试过了
pip install python-magic-bin==0.4.14
我也试过
!brew install libmagic
但Colab似乎不认识brew
在 Colab 上安装 Libmagic 的方式如下:
!apt-get install libmagic-dev
!pip install python-magic
然后,您可以毫无问题地导入它:
import magic
典型的 Colab 链接