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

ImportError: No module named 'decls' #32

Closed
matrey opened this issue Mar 1, 2018 · 12 comments
Closed

ImportError: No module named 'decls' #32

matrey opened this issue Mar 1, 2018 · 12 comments

Comments

@matrey
Copy link
Contributor

matrey commented Mar 1, 2018

Hi

I get the following error when importing pyvips:

$ python testvips.py 
DEBUG:pyvips:Binary module load failed: No module named '_libvips'
DEBUG:pyvips:Falling back to ABI mode
DEBUG:pyvips:Loaded lib <cffi.api._make_ffi_library.<locals>.FFILibrary object at 0x7fd20b984278>
DEBUG:pyvips:Loaded lib <cffi.api._make_ffi_library.<locals>.FFILibrary object at 0x7fd20b9e1eb8>
DEBUG:pyvips:Inited libvips
DEBUG:pyvips:
Traceback (most recent call last):
  File "testvips.py", line 4, in <module>
    import pyvips
  File "/REDACTED/.venv/lib/python3.5/site-packages/pyvips/__init__.py", line 75, in <module>
    import decls
ImportError: No module named 'decls'

I tried on 2 machines with the same result:

  • Ubuntu 16.04.1 LTS, Python 3.5.2
  • Ubuntu 17.04, Python 3.5.3

I ran sudo apt-get install libvips libvips-dev libvips-tools --no-install-recommends
Then in my virtualenv pip install pyvips
pip show tells me pyvips is Version: 2.1.1 in ABI mode

Is there anything I missed?

@jcupitt
Copy link
Member

jcupitt commented Mar 1, 2018

Huh strange, decls is just part of pyvips:

https://github.com/jcupitt/pyvips/blob/master/pyvips/decls.py

I'll try to investigate.

@jcupitt
Copy link
Member

jcupitt commented Mar 1, 2018

If you have libvips-dev on there, it should work in API mode. Perhaps you have a cached binary wheel for pyvips? You could try deleting that and doing pip install pyvips again.

@jcupitt
Copy link
Member

jcupitt commented Mar 1, 2018

Also, which python are you using? It's currently passing with 2.7, 3.5 and 3.6, but failing with 3.3 and 3.4 due to a strange dependency problem.

https://travis-ci.org/jcupitt/pyvips/builds/345887526

@matrey
Copy link
Contributor Author

matrey commented Mar 1, 2018

I'm using Python 3.5 on both machines, within a virtualenv.
Checking on your remark "Perhaps you have a cached binary wheel for pyvips", I ran:

$ pip install --no-cache-dir pyvips
Collecting pyvips
  Downloading pyvips-2.1.1.tar.gz
Requirement already satisfied: cffi>=1.0.0 in ./.venv/lib/python3.5/site-packages (from pyvips)
Collecting pkgconfig (from pyvips)
  Downloading pkgconfig-1.3.1.tar.gz
Requirement already satisfied: pycparser in ./.venv/lib/python3.5/site-packages (from cffi>=1.0.0->pyvips)
Installing collected packages: pkgconfig, pyvips
  Running setup.py install for pkgconfig ... done
  Running setup.py install for pyvips ... done
Successfully installed pkgconfig-1.3.1 pyvips-2.1.1
$ pip show pyvips
Name: pyvips
Version: 2.1.1
Summary: binding for the libvips image processing library, API mode
Home-page: https://github.com/jcupitt/pyvips
Author: John Cupitt
Author-email: jcupitt@gmail.com
License: MIT
Location: /data/work/storeprint/python/.venv/lib/python3.5/site-packages
Requires: cffi, pkgconfig

This time it seems to report being installed in API mode rather than ABI.
However, this still doesn't help running the sample code (though the error seems a bit different this time):

$ python testpyvips.py 
DEBUG:pyvips:Binary module load failed: /REDACTED/.venv/lib/python3.5/site-packages/_libvips.abi3.so: undefined symbol: vips_image_get_fields
DEBUG:pyvips:Falling back to ABI mode
DEBUG:pyvips:Loaded lib <cffi.api._make_ffi_library.<locals>.FFILibrary object at 0x7f5f99d7f128>
DEBUG:pyvips:Loaded lib <cffi.api._make_ffi_library.<locals>.FFILibrary object at 0x7f5f9a24cfd0>
DEBUG:pyvips:Inited libvips
DEBUG:pyvips:
Traceback (most recent call last):
  File "testpyvips.py", line 4, in <module>
    import pyvips
  File "/REDACTED/.venv/lib/python3.5/site-packages/pyvips/__init__.py", line 75, in <module>
    import decls
ImportError: No module named 'decls'

Could it be related to the virtualenv? or to the fact I used "--no-install-recommends" for the libraries (sudo apt-get install libvips libvips-dev libvips-tools --no-install-recommends)?

@jcupitt
Copy link
Member

jcupitt commented Mar 1, 2018

Hello again, you've hit another bug, sorry:

https://github.com/jcupitt/pyvips/issues/33

Could you try git master pyvips? That one should be fixed now.

pyvips 2.1 has a big change to the way it installs :-( it seems to be causing trouble.

@jcupitt
Copy link
Member

jcupitt commented Mar 1, 2018

Oop, I was reading too quickly, that's a different problem.

I'll have another look at your decls issue.

@matrey
Copy link
Contributor Author

matrey commented Mar 1, 2018

By the way here are my libvips versions:

  • Ubuntu 16.04.1 LTS, Python 3.5.2 --> libvips 8.2.2-1
  • Ubuntu desktop 17.04, Python 3.5.3 --> libvips 8.4.5-1build1 (installed libvips, libvips-dev, libvips-tools)

Doing the test on the latter (with libvips 8.4.5-1build1), using the most recent commit on master:

$ pip install --no-cache-dir git+git://github.com/jcupitt/pyvips.git@2bcaf01dbed6e7df117be1a004664e918827ee82
Collecting git+git://github.com/jcupitt/pyvips.git@2bcaf01dbed6e7df117be1a004664e918827ee82
  Cloning git://github.com/jcupitt/pyvips.git (to 2bcaf01dbed6e7df117be1a004664e918827ee82) to /tmp/pip-do7k84bu-build
  Could not find a tag or branch '2bcaf01dbed6e7df117be1a004664e918827ee82', assuming commit.
Requirement already satisfied: cffi>=1.0.0 in ./.venv/lib/python3.5/site-packages (from pyvips==2.1.2)
Requirement already satisfied: pkgconfig in ./.venv/lib/python3.5/site-packages (from pyvips==2.1.2)
Requirement already satisfied: pycparser in ./.venv/lib/python3.5/site-packages (from cffi>=1.0.0->pyvips==2.1.2)
Installing collected packages: pyvips
  Found existing installation: pyvips 2.1.1
    Uninstalling pyvips-2.1.1:
      Successfully uninstalled pyvips-2.1.1
  Running setup.py install for pyvips ... done
Successfully installed pyvips-2.1.2
$ pip show pyvips
Name: pyvips
Version: 2.1.2
Summary: binding for the libvips image processing library, API mode
...

Now, it works! No more decls issue.

DEBUG:pyvips:Loaded binary module _libvips
DEBUG:pyvips:Inited libvips
DEBUG:pyvips:
test Image
DEBUG:pyvips.voperation:VipsOperation.call: operation_name = VipsForeignLoadPng
DEBUG:pyvips.voperation:VipsOperation.call: string_options = 
DEBUG:pyvips.voperation:VipsOperation.call: match_image = None
DEBUG:pyvips.vobject:VipsObject.set: name = filename, value = /REDACTED.png
DEBUG:pyvips.vobject:VipsObject.get: name = out
DEBUG:pyvips.vobject:VipsObject.get: name = width
DEBUG:pyvips.vobject:VipsObject.get: name = height
DEBUG:pyvips.vobject:VipsObject.get: name = format
DEBUG:pyvips.vobject:VipsObject.get: name = bands
DEBUG:pyvips.vobject:VipsObject.get: name = interpretation
DEBUG:pyvips.voperation:VipsOperation.call: result = <pyvips.Image 1812x859 uchar, 4 bands, srgb>
DEBUG:pyvips.vobject:VipsObject.get: name = width
DEBUG:pyvips.vobject:VipsObject.get: name = height
DEBUG:pyvips.vobject:VipsObject.get: name = format
DEBUG:pyvips.vobject:VipsObject.get: name = bands
DEBUG:pyvips.vobject:VipsObject.get: name = interpretation
image = <pyvips.Image 1812x859 uchar, 4 bands, srgb>
DEBUG:pyvips.vobject:VipsObject.get: name = width
image.width = 1812

@matrey
Copy link
Contributor Author

matrey commented Mar 1, 2018

Testing on my other platform: Ubuntu (server) 16.04.1 LTS, Python 3.5.2 --> libvips 8.2.2-1.
On that one I only installed libvips (not -dev) so I'd expect it to use ABI

Installing the same version

$ pip install --no-cache-dir git+git://github.com/jcupitt/pyvips.git@2bcaf01dbed6e7df117be1a004664e918827ee82
Collecting git+git://github.com/jcupitt/pyvips.git@2bcaf01dbed6e7df117be1a004664e918827ee82
  Cloning git://github.com/jcupitt/pyvips.git (to 2bcaf01dbed6e7df117be1a004664e918827ee82) to /tmp/pip-vrkoekaa-build
  Could not find a tag or branch '2bcaf01dbed6e7df117be1a004664e918827ee82', assuming commit.
Requirement already satisfied: cffi>=1.0.0 in ./.venv/lib/python3.5/site-packages (from pyvips==2.1.2)
Requirement already satisfied: pycparser in ./.venv/lib/python3.5/site-packages (from cffi>=1.0.0->pyvips==2.1.2)
Installing collected packages: pyvips
  Found existing installation: pyvips 2.1.1
    Uninstalling pyvips-2.1.1:
      Successfully uninstalled pyvips-2.1.1
  Running setup.py install for pyvips ... done
Successfully installed pyvips-2.1.2
$ pip show pyvips
Name: pyvips
Version: 2.1.2
Summary: binding for the libvips image processing library, ABI mode
...

Now the test...

$ python testvips.py 
DEBUG:pyvips:Binary module load failed: No module named '_libvips'
DEBUG:pyvips:Falling back to ABI mode
DEBUG:pyvips:Loaded lib <cffi.api._make_ffi_library.<locals>.FFILibrary object at 0x7f4e25ad22e8>
DEBUG:pyvips:Loaded lib <cffi.api._make_ffi_library.<locals>.FFILibrary object at 0x7f4e25b33f28>
DEBUG:pyvips:Inited libvips
DEBUG:pyvips:
Traceback (most recent call last):
  File "testvips.py", line 4, in <module>
    import pyvips
  File "/REDACTED/.venv/lib/python3.5/site-packages/pyvips/__init__.py", line 75, in <module>
    import decls
ImportError: No module named 'decls'

So the "decls" issue still seems to be happening under these conditions:

  • Ubuntu (server) 16.04.1 LTS
  • Python 3.5.2
  • libvips 8.2.2-1 (and without -dev)
  • pyvips master@2bcaf01dbed6e7df117be1a004664e918827ee82

@jcupitt
Copy link
Member

jcupitt commented Mar 1, 2018

Some progress! Thank you for being so patient with this.

Could you try master again? I made decls a relative import, perhaps it'll help.

@jcupitt
Copy link
Member

jcupitt commented Mar 1, 2018

Oh dear, that was silly. Try again, it's working for me now.

@matrey
Copy link
Contributor Author

matrey commented Mar 2, 2018

Good news! No more error on Ubuntu (server) 16.04.1 LTS + libvips 8.2.2-1 (without -dev) / ABI mode

$ pip install --upgrade --no-cache-dir git+git://github.com/jcupitt/pyvips.git@4df6fb5a7b50a6ba540c7fad529df7272c7efe51
Collecting git+git://github.com/jcupitt/pyvips.git@4df6fb5a7b50a6ba540c7fad529df7272c7efe51
  Cloning git://github.com/jcupitt/pyvips.git (to 4df6fb5a7b50a6ba540c7fad529df7272c7efe51) to /tmp/pip-riwrh6b2-build
  Could not find a tag or branch '4df6fb5a7b50a6ba540c7fad529df7272c7efe51', assuming commit.
Collecting cffi>=1.0.0 (from pyvips==2.1.2)
  Downloading cffi-1.11.5-cp35-cp35m-manylinux1_x86_64.whl (420kB)
    100% |████████████████████████████████| 430kB 91kB/s 
Requirement already up-to-date: pycparser in ./.venv/lib/python3.5/site-packages (from cffi>=1.0.0->pyvips==2.1.2)
Installing collected packages: cffi, pyvips
  Found existing installation: cffi 1.10.0
    Uninstalling cffi-1.10.0:
      Successfully uninstalled cffi-1.10.0
  Found existing installation: pyvips 2.1.2
    Uninstalling pyvips-2.1.2:
      Successfully uninstalled pyvips-2.1.2
  Running setup.py install for pyvips ... done
Successfully installed cffi-1.11.5 pyvips-2.1.2
$ pip show pyvips
Name: pyvips
Version: 2.1.2
Summary: binding for the libvips image processing library, ABI mode
...
$ python testvips.py 
DEBUG:pyvips:Binary module load failed: No module named '_libvips'
DEBUG:pyvips:Falling back to ABI mode
DEBUG:pyvips:Loaded lib <cffi.api._make_ffi_library.<locals>.FFILibrary object at 0x7fe78636e5c0>
DEBUG:pyvips:Loaded lib <cffi.api._make_ffi_library.<locals>.FFILibrary object at 0x7fe786842eb8>
DEBUG:pyvips:Inited libvips
DEBUG:pyvips:
test Image
DEBUG:pyvips.voperation:VipsOperation.call: operation_name = VipsForeignLoadPng
DEBUG:pyvips.voperation:VipsOperation.call: string_options = 
DEBUG:pyvips.voperation:VipsOperation.call: match_image = None
DEBUG:pyvips.vobject:VipsObject.set: name = filename, value = /REDACTED/pricedrop.png
DEBUG:pyvips.vobject:VipsObject.get: name = out
DEBUG:pyvips.vobject:VipsObject.get: name = width
DEBUG:pyvips.vobject:VipsObject.get: name = height
DEBUG:pyvips.vobject:VipsObject.get: name = format
DEBUG:pyvips.vobject:VipsObject.get: name = bands
DEBUG:pyvips.vobject:VipsObject.get: name = interpretation
DEBUG:pyvips.voperation:VipsOperation.call: result = <pyvips.Image 1812x859 uchar, 4 bands, srgb>
DEBUG:pyvips.vobject:VipsObject.get: name = width
DEBUG:pyvips.vobject:VipsObject.get: name = height
DEBUG:pyvips.vobject:VipsObject.get: name = format
DEBUG:pyvips.vobject:VipsObject.get: name = bands
DEBUG:pyvips.vobject:VipsObject.get: name = interpretation
image = <pyvips.Image 1812x859 uchar, 4 bands, srgb>
DEBUG:pyvips.vobject:VipsObject.get: name = width
image.width = 1812

I also re-checked the other platform just in case.
Ubuntu desktop 17.04, Python 3.5.3, libvips 8.4.5-1build1 (installed libvips, libvips-dev, libvips-tools)

  • with dev headers installed, API mode --> OK
  • after uninstalling the dev headers, ABI mode --> OK

@jcupitt
Copy link
Member

jcupitt commented Mar 2, 2018

Great! I'll merge your PR too. Thank you again for reporting this.

@jcupitt jcupitt closed this as completed Mar 2, 2018
jcupitt added a commit that referenced this issue Mar 2, 2018
Add a few notes following #32 and #33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants