Magic.open python 的magic模块没有open函数问题

各种坑,用过

pip install python-magic

pip install python-libmagic

pip install python-magic-bin

都不行

直到看到

Name Conflict

There are, sadly, two libraries which use the module name magic. Both have been around for quite a while. If you are using this module and get an error using a method like open, your code is expecting the other one. Hopefully one day these will be reconciled.

才知道原来有另一个同名的magic,但是是什么呢?不清楚

直到找到这篇文章

https://stackoverflow.com/questions/43580/how-to-find-the-mime-type-of-a-file-in-python

直到这个好心人mammadori的出现

here are 3 different libraries that wraps libmagic.

2 of them are available on pypi (so pip install will work):

  • filemagic
  • python-magic

And another, similar to python-magic is available directly in the latest libmagic sources, and it is the one you probably have in your linux distribution.

In Debian the package python-magic is about this one and it is used as toivotuo said and it is not obsoleted as Simon Zimmermann said (IMHO).

It seems to me another take (by the original author of libmagic).

Too bad is not available directly on pypi.

I added a repo for convenience: github.com/mammadori/magic-python that way you can:

pip install -e git://github.com/mammadori/magic-python.git#egg=Magic_file_extensions

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值