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

python setup.py install doesn't install snappy._snappy_cffi module #83

Open
todofixthis opened this issue Jul 22, 2019 · 5 comments
Open

Comments

@todofixthis
Copy link

Related: #78, #69

Repro

macOS 10.14.5, in a virtualenv with Python 3.6.9, python-snappy v0.5.4 (commit 602e9c1)

  1. git clone https://github.com/andrix/python-snappy
  2. cd python-snappy
  3. git checkout master
  4. python setup.py build
  5. python setup.py install

Testing in IPython fails with the following error:

In [1]: import snappy
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
~/Documents/python-snappy/snappy/snappy.py in <module>()
     47 try:
---> 48     from ._snappy import UncompressError, compress, decompress, \
     49                          isValidCompressed, uncompress, _crc32c

ModuleNotFoundError: No module named 'snappy._snappy'

During handling of the above exception, another exception occurred:

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-710a7f18823c> in <module>()
----> 1 import snappy

~/Documents/python-snappy/snappy/__init__.py in <module>()
      1 from __future__ import absolute_import
      2
----> 3 from .snappy import (
      4         compress,
      5         decompress,

~/Documents/python-snappy/snappy/snappy.py in <module>()
     49                          isValidCompressed, uncompress, _crc32c
     50 except ImportError:
---> 51     from .snappy_cffi import UncompressError, compress, decompress, \
     52                              isValidCompressed, uncompress, _crc32c
     53

~/Documents/python-snappy/snappy/snappy_cffi.py in <module>()
      1 from __future__ import absolute_import
      2
----> 3 from ._snappy_cffi import ffi, lib
      4
      5 try:

ModuleNotFoundError: No module named 'snappy._snappy_cffi'

Workaround

  1. python setup.py bdist_egg
  2. cd dist
  3. unzip python_snappy-0.5.4-py3.6-macosx-10.14-x86_64.egg
  4. cd snappy
  5. cp _snappy_cffi.abi3.so "${VIRTUAL_ENV}/lib/python3.6/site-packages/snappy/"

After performing the above steps, it is now possible to import snappy in a python shell without error.

(might also need to copy _snappy.py and _snappy.cpython-36m-darwin.so; not sure)

It appears that python setup.py install does not install these files.

@todofixthis todofixthis changed the title setup.py doesn't install _snappy_cffi.py setup.py doesn't install snappy._snappy_cffi module Jul 22, 2019
@todofixthis todofixthis changed the title setup.py doesn't install snappy._snappy_cffi module python setup.py install doesn't install snappy._snappy_cffi module Jul 22, 2019
@jianglijie
Copy link

Is this problem solved?I also found the same problem with python 3.6

@melinath
Copy link

I was getting a similar error and it turned out the problem was that I needed to brew install snappy to get the necessary underlying libraries.

@datalw
Copy link

datalw commented Feb 24, 2021

I also had similar issue with python 3.8.5 on windows. I posted here earlier.

@martindurant
Copy link
Member

In summary: it is not expected that python-snappy knows how to install the snappy binary shared object. If installing via source, that binary (and dev/headers) must be available at install time. We now have many binary wheels available, but snappy still needs to be installed at run time.
If you are using conda, then this binary dependency will be filled for you.

@datalw
Copy link

datalw commented Feb 24, 2021

Thanks a lot for the reply. It was installed by conda, as shown in the pkg details in the referenced post, but the error was still there.

I just found a workaround to solve this temprarily: I downloaded the wheel file of python-snappy from the PyPI website and manually installed it via pip install --force-reinstall python_snappy-0.6.0-cp38-cp38-win_amd64.whl and this error disappeared.

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

5 participants