【问题标题】:Error in trying to install/use Python-Magic in Google Colab尝试在 Google Colab 中安装/使用 Python-Magic 时出错
【发布时间】:2019-11-02 18:10:04
【问题描述】:

我正在尝试在 Colab 中安装 python-magic。这里是库的 Github https://github.com/ahupp/python-magic#dependencies

当我尝试时:

!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

您的多重上传表单可能使用 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

【问题讨论】:

    标签: python google-colaboratory python-magic


    【解决方案1】:

    在 Colab 上安装 Libmagic 的方式如下:

    !apt-get install libmagic-dev
    !pip install python-magic
    

    然后,您可以毫无问题地导入它:

    import magic
    

    An exemplary Colab link

    【讨论】:

      猜你喜欢
      • 2022-11-13
      • 2020-12-06
      • 1970-01-01
      • 2019-08-09
      • 2023-01-07
      • 2022-08-13
      • 1970-01-01
      • 2019-01-30
      • 2021-08-29
      相关资源
      最近更新 更多