Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libmagic error following messytables overview #104

Closed
dhalperi opened this issue Feb 28, 2014 · 8 comments
Closed

libmagic error following messytables overview #104

dhalperi opened this issue Feb 28, 2014 · 8 comments

Comments

@dhalperi
Copy link

I'm based off of http://messytables.readthedocs.org/en/latest/ but have also looked at the GitHub readme, etc. Couldn't find any actual install instructions anywhere, but here's what I did.

Environment: Mac OS X latest, up to date homebrew

  1. pip install messytables

  2. brew install libmagic

  3. The following Python:

    % python                
    Python 2.7.6 (default, Nov 14 2013, 09:55:56) 
    [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import messytables
    >>> messytables.any_tableset(open('README.txt', 'rb'))
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/local/lib/python2.7/site-packages/messytables/any.py", line 138, in any_tableset
        magic_mime = get_mime(fileobj)
      File "/usr/local/lib/python2.7/site-packages/messytables/any.py", line 38, in get_mime
        mimetype = magic.from_buffer(header, mime=True)
      File "build/bdist.macosx-10.9-x86_64/egg/magic.py", line 103, in from_buffer
        def __init__(self, ms):
      File "build/bdist.macosx-10.9-x86_64/egg/magic.py", line 94, in _get_magic_type
        _list = _libraries['magic'].magic_list
      File "build/bdist.macosx-10.9-x86_64/egg/magic.py", line 83, in _get_magic_mime
        _load.restype = c_int
      File "build/bdist.macosx-10.9-x86_64/egg/magic.py", line 51, in __init__
        magic_set._fields_ = []
      File "build/bdist.macosx-10.9-x86_64/egg/magic.py", line 138, in errorcheck
        except:
    magic.MagicException: no magic files loaded
  4. README.txt:

    ============
    README
    ============
    
    A single-line README file.
    
@dhalperi
Copy link
Author

I could imagine you arguing there's no table here, or defending one of many types of tables. But in any case, this seems like the wrong error. Docs say:

On error it raises messytables.ReadError

@domoritz
Copy link
Contributor

Hmm, cannot reproduce this error with libmagic-5.17.

Python 2.7.6 (default, Nov 20 2013, 22:26:18)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import messytables
>>> messytables.any_tableset(open('README.txt', 'rb'))
<messytables.commas.CSVTableSet object at 0x1045df590>
>>>

@dhalperi
Copy link
Author

Do you have any files in your local directories? Various google hints point at files like ~/.magic. http://askubuntu.com/questions/105652/where-is-the-file-used-by-file1-and-libmagic-to-determine-mime-types

@dhalperi
Copy link
Author

Possibly a known issue, albeit one that messytables does not currently let us work around: https://github.com/ahupp/python-magic#troubleshooting

@domoritz
Copy link
Contributor

No. ls -lah ~ | grep magic is empty.

@dhalperi
Copy link
Author

Figured it out.

ahupp/python-magic#44

I had magic 0.4.3 installed, upgrading to 0.4.6 fixed it. Thanks!

% pip install --upgrade python-magic
Downloading/unpacking python-magic from https://pypi.python.org/packages/source/p/python-magic/python-magic-0.4.6.tar.gz#md5=07e7a0fea78dd81ed609414c3484df58
  Downloading python-magic-0.4.6.tar.gz
  Running setup.py (path:/private/var/folders/m_/qltd_g_13qd1v5tvr4l6q2rc0000gn/T/pip_build_dhalperi/python-magic/setup.py) egg_info for package python-magic

Installing collected packages: python-magic
  Found existing installation: python-magic 0.4.3
    Uninstalling python-magic:
      Successfully uninstalled python-magic
  Running setup.py install for python-magic

Successfully installed python-magic
Cleaning up...

@domoritz
Copy link
Contributor

Hehe, #101.

@dhalperi
Copy link
Author

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants