簡體   English   中英

嘗試在Google Colab中安裝/使用Python-Magic時出錯

[英]Error in trying to install/use Python-Magic in Google Colab

我正在嘗試在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:找不到libmagic。 在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

從這個帖子

pip安裝eyeD3模塊。 找不到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鏈接

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM