Nixpkgs: s3cmd: module python-magic is not available

Created on 2 Mar 2016  路  7Comments  路  Source: NixOS/nixpkgs

When uploading with s3cmd:

WARNING: Module python-magic is not available. Guessing MIME types based on file extensions.

s3cmd has

{
propagatedBuildInputs = with pythonPackages; [ python_magic dateutil ];
}

But is seems pointless at all.

Should a wrapper be used?

{
    buildInputs = with pythonPackages; [ python_magic dateutil wrapPython ];
    # ^^ is this enough?
    pythonPath = with pythonPackages; [ python_magic ];
}
stale python

Most helpful comment

Here's a solution that worked for me:

  1. Observe in the code that import magic is what's triggering the "Module python-magic is not available" error msg:
  2. Repro the failing import to get more information:
$ python -c 'import magic'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/danb/miniconda3/lib/python3.6/site-packages/magic.py", line 181, in <module>
    raise ImportError('failed to find libmagic.  Check your installation')
ImportError: failed to find libmagic.  Check your installation
  1. Since I'm using conda, I can reinstall the python-magic package to get the native libmagic dependency. If you aren't using conda, then something like brew install libmagic (osx) or apt-get install libmagic-dev (ubuntu) might work.
$ conda install -y python-magic
...
The following NEW packages will be INSTALLED:

    libmagic:     5.32-0                                conda-forge
    libopenblas:  0.2.20-hdc02c5d_7
    numpy-base:   1.14.3-py36h7ef55bc_1
    python-magic: 0.4.15-py36_0                         conda-forge
...
  1. Re-run the import to verify that it no longer fails:
$ python -c 'import magic'

All 7 comments

There are two python-magic packages, try the other one :)

@ip1981 is this issue solved?

No :-)

domenkozar wrote:

There are two python-magic packages, try the other one :)

How would one go about doing that? pip install python-magic didn't resolve the issue.

There are two python-magic packages, try the other one :)

+1 That's not a helpful comment.

Here's a solution that worked for me:

  1. Observe in the code that import magic is what's triggering the "Module python-magic is not available" error msg:
  2. Repro the failing import to get more information:
$ python -c 'import magic'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/danb/miniconda3/lib/python3.6/site-packages/magic.py", line 181, in <module>
    raise ImportError('failed to find libmagic.  Check your installation')
ImportError: failed to find libmagic.  Check your installation
  1. Since I'm using conda, I can reinstall the python-magic package to get the native libmagic dependency. If you aren't using conda, then something like brew install libmagic (osx) or apt-get install libmagic-dev (ubuntu) might work.
$ conda install -y python-magic
...
The following NEW packages will be INSTALLED:

    libmagic:     5.32-0                                conda-forge
    libopenblas:  0.2.20-hdc02c5d_7
    numpy-base:   1.14.3-py36h7ef55bc_1
    python-magic: 0.4.15-py36_0                         conda-forge
...
  1. Re-run the import to verify that it no longer fails:
$ python -c 'import magic'

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.
Was this page helpful?
0 / 5 - 0 ratings