python-magic is incomplete on Ubuntu LTS?

Bug #603128 reported by Joubert on 2010-07-08
42
This bug affects 8 people
Affects Status Importance Assigned to Milestone
file (Ubuntu)
High
Unassigned

Bug Description

Binary package hint: file

I'm running Ubuntu 10.04 LTS.

I installed python-magic with: sudo apt-get install python-magic (the file that gets installed is python-magic_5.03-5ubuntu1_i386.deb)

However, when I start Python (version 2.6.5) and I "import magic" and I then do "dir(magic)", it seems as though the module does not contain all the definitions that I can see on python-magic's github repo (i.e. the Ubuntu package seems outdated):

['MAGIC_APPLE', 'MAGIC_CHECK', 'MAGIC_COMPRESS', 'MAGIC_CONTINUE', 'MAGIC_DEBUG', 'MAGIC_DEVICES', 'MAGIC_ERROR', 'MAGIC_MIME', 'MAGIC_MIME_ENCODING', 'MAGIC_MIME_TYPE', 'MAGIC_NONE', 'MAGIC_NO_CHECK_APPTYPE', 'MAGIC_NO_CHECK_CDF', 'MAGIC_NO_CHECK_COMPRESS', 'MAGIC_NO_CHECK_ELF', 'MAGIC_NO_CHECK_ENCODING', 'MAGIC_NO_CHECK_SOFT', 'MAGIC_NO_CHECK_TAR', 'MAGIC_NO_CHECK_TEXT', 'MAGIC_NO_CHECK_TOKENS', 'MAGIC_PRESERVE_ATIME', 'MAGIC_RAW', 'MAGIC_SYMLINK', '__doc__', '__file__', '__name__', '__package__', 'error', 'open']

What's up? Am I doing something wrong?

Joubert

I have the same problem on natty with python-magic 5.04-5ubuntu2 and python 2.7.1-0ubuntu5.

The magic module does not contain the Magic class, rendering the module useless.

On the off chance someone doesn't know, a workaround is:
sudo apt-get remove python-magic
sudo apt-get install python-pip
sudo pip install python-magic

Changed in file (Ubuntu):
status: New → Confirmed

Seems to be broken on Ubuntu 12.04 and 13.10 and possibly all versions between that.

Not sure what is up with this, is this actually a different library than "pip install python-magic" will install???

>>> import magic
>>> magic.from_buffer
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'from_buffer'

Also I noticed the version is completely wrong it's like version 5.04 when python-magic on pip is 0.4.6, what is up with that?

https://pypi.python.org/pypi/python-magic/

Unfortunately I need this package desperately, so I am going to have to package it up myself and bump up the version of the package, even though it's wrong, so that it will overinstall the broken python-magic package.

Rob van der Linde (robvdl) wrote :

I had quick a look inisde the Ubuntu 12.04 package for python-magic and it definitely appears to be the same library as on pip, it's just a very old version which doesn't appear to be very useful at all, also it's not versioned correctly, it has the same version as libmagic (5.09-2) but it should really by 0.4.6 if the latest from pip was to be packaged.

Pander (pander) wrote :
Download full text (5.8 KiB)

Is this fixed now?

On Xenial:

# apt-get install python-magic
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  python-magic
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 5,374 B of archives.
After this operation, 54.3 kB of additional disk space will be used.
Get:1 http://nl.archive.ubuntu.com/ubuntu xenial/universe amd64 python-magic all 1:5.25-2ubuntu1 [5,374 B]
Fetched 5,374 B in 0s (27.8 kB/s)
Selecting previously unselected package python-magic.
(Reading database ... 305679 files and directories currently installed.)
Preparing to unpack .../python-magic_1%3a5.25-2ubuntu1_all.deb ...
Unpacking python-magic (1:5.25-2ubuntu1) ...
Setting up python-magic (1:5.25-2ubuntu1) ...

# python
Python 2.7.11+ (default, Apr 17 2016, 14:00:29)
[GCC 5.3.1 20160413] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import magic
>>> dir(magic)
['APPLE', 'ARRAY', 'ArgumentError', 'Array', 'BigEndianStructure', 'CDLL', 'CFUNCTYPE', 'CHECK', 'COMPRESS', 'CONTINUE', 'DEBUG', 'DEFAULT_MODE', 'DEVICES', 'ERROR', 'LibraryLoader', 'LittleEndianStructure', 'MAGIC_APPLE', 'MAGIC_CHECK', 'MAGIC_COMPRESS', 'MAGIC_CONTINUE', 'MAGIC_DEBUG', 'MAGIC_DEVICES', 'MAGIC_ERROR', 'MAGIC_MIME', 'MAGIC_MIME_ENCODING', 'MAGIC_MIME_TYPE', 'MAGIC_NONE', 'MAGIC_NO_CHECK_APPTYPE', 'MAGIC_NO_CHECK_BUILTIN', 'MAGIC_NO_CHECK_CDF', 'MAGIC_NO_CHECK_COMPRESS', 'MAGIC_NO_CHECK_ELF', 'MAGIC_NO_CHECK_ENCODING', 'MAGIC_NO_CHECK_SOFT', 'MAGIC_NO_CHECK_TAR', 'MAGIC_NO_CHECK_TEXT', 'MAGIC_NO_CHECK_TOKENS', 'MAGIC_PRESERVE_ATIME', 'MAGIC_RAW', 'MAGIC_SYMLINK', 'MIME', 'MIME_ENCODING', 'MIME_TYPE', 'Magic', 'NONE', 'NO_CHECK_APPTYPE', 'NO_CHECK_BUILTIN', 'NO_CHECK_CDF', 'NO_CHECK_COMPRESS', 'NO_CHECK_ELF', 'NO_CHECK_ENCODING', 'NO_CHECK_SOFT', 'NO_CHECK_TAR', 'NO_CHECK_TEXT', 'NO_CHECK_TOKENS', 'POINTER', 'PRESERVE_ATIME', 'PYFUNCTYPE', 'PyDLL', 'RAW', 'RTLD_GLOBAL', 'RTLD_LOCAL', 'SYMLINK', 'SetPointerType', 'Structure', 'Union', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '_buffer', '_check', '_close', '_compile', '_descriptor', '_errno', '_error', '_file', '_init', '_libraries', '_list', '_load', '_open', '_setflags', 'addressof', 'alignment', 'byref', 'c_bool', 'c_buffer', 'c_byte', 'c_char', 'c_char_p', 'c_double', 'c_float', 'c_int', 'c_int16', 'c_int32', 'c_int64', 'c_int8', 'c_long', 'c_longdouble', 'c_longlong', 'c_short', 'c_size_t', 'c_ssize_t', 'c_ubyte', 'c_uint', 'c_uint16', 'c_uint32', 'c_uint64', 'c_uint8', 'c_ulong', 'c_ulonglong', 'c_ushort', 'c_void_p', 'c_voidp', 'c_wchar', 'c_wchar_p', 'cast', 'cdll', 'create_string_buffer', 'create_unicode_buffer', 'ctypes', 'find_library', 'get_errno', 'magic_set', 'magic_t', 'memmove', 'memset', 'open', 'pointer', 'py_object', 'pydll', 'pythonapi', 'resize', 'set_conversion_mode', 'set_errno', 'sizeof', 'string_at', 'wstring_at']

# apt-get install python3-magic
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  python3-magic
0 upgraded, 1 newly installed, 0 to re...

Read more...

Pander (pander) on 2016-06-24
tags: added: xenial yakkety
summary: - python-magic is incomplete on Ubuntu 10.04 LTS?
+ python-magic is incomplete on Ubuntu LTS?
Changed in file (Ubuntu):
importance: Undecided → High
Pander (pander) wrote :

While fixing this, please upgrade to latest stable version of July 2016.

tags: added: upgrade-software-version
removed: xenial
Pander (pander) on 2016-10-25
tags: added: zesty
Pander (pander) on 2017-02-25
tags: removed: yakkety
Pander (pander) on 2017-05-02
tags: added: artful
Tony Caduto (snorkel12068) wrote :

Libmagic1 is broke on 16.04 as well. reports XLS files application/CDFV2-unknown

needs to be updated to version 5.31 or greater.

Pander (pander) on 2018-03-20
tags: added: bionic
Pander (pander) on 2018-05-06
tags: added: cosmic
removed: artful zesty
Pander (pander) on 2018-11-02
tags: added: disco
removed: bionic cosmic
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers