Arch Linux

Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#23445 - [opencv] python interface not responding

Attached to Project: Arch Linux
Opened by Lazarus (Lazarus) - Saturday, 26 March 2011, 02:32 GMT
Last edited by Ray Rashif (schivmeister) - Tuesday, 05 April 2011, 08:48 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Ray Rashif (schivmeister)
Architecture All
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Currently the package places only a "cv.so" file in the usr/lib/python2.7/site-packages directory, which unsurprisingly seems to be insufficient; I can "import cv", but nothing is imported except "__file__". I have python2-numpy installed.

Since the release of opencv2.2, python support has apparently been completely reworked and considerably improved, so I would appreciate it if this package be built in a way that allows me to use this functionality...

Some instructions here: http://opencv.willowgarage.com/wiki/InstallGuide
This task depends upon

Closed by  Ray Rashif (schivmeister)
Tuesday, 05 April 2011, 08:48 GMT
Reason for closing:  Works for me
Additional comments about closing:  Reopen if necessary.
Comment by Lazarus (Lazarus) - Saturday, 26 March 2011, 02:35 GMT
"compile" in the title should probably read "configure" or some such, but whatever...
Comment by Ray Rashif (schivmeister) - Wednesday, 30 March 2011, 18:57 GMT
I'm pretty sure I went over http://opencv.willowgarage.com/wiki/PythonInterface (or http://opencv.willowgarage.com/documentation/python/cookbook.html) and found everything to work. Could you please do that? Thanks. I spent a considerable amount of time making sure the python support was all in because at that time I was working on a project myself.
Comment by Lazarus (Lazarus) - Thursday, 31 March 2011, 05:04 GMT
> Could you please do that?

If you had grasped the meaning of my bug report, you'd notice I already did..

$ python2
Python 2.7.1 (r271:86832, Feb 21 2011, 01:28:26)
[GCC 4.5.2 20110127 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv
['__builtins__', '__doc__', '__file__', '__name__', '__package__']
>>> cv.LoadImageM('test.jpg', 1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'LoadImageM'
>>>

Everything in the cookbooks you linked to result in an AttributeError such as the one above, because --I repeat-- importing cv with your package (on my machine at least) doesn't import any attributes of cv into the global namespace (attributes of the form __name__ are attributes of the python interpreter itself).

I very much appreciate that you went to considerable lengths to include python, but please verify that what you say worked before still works *now*, because --I repeat yet again-- the opencv python module has apparently been reworked since version 2.2.
Comment by Ray Rashif (schivmeister) - Thursday, 31 March 2011, 07:40 GMT
I _am_ talking about 2.2 _now_:

[schiv@cq60 ~]$ pacman -Q opencv python2
opencv 2.2.0-3
python2 2.7.1-7
[schiv@cq60 ~]$ python2
Python 2.7.1 (r271:86832, Feb 21 2011, 01:26:25)
[GCC 4.5.2 20110127 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv
>>> cv.LoadImageM('openshot.png', 1)
<cvmat(type=42424010 8UC3 rows=768 cols=1366 step=4098 )>

You are now going to follow my lead and verify this for yourself, before you accuse me again of incompetence in that tone:

# pacman -S devtools
# extra-i686-build
# cd /var/tmp/archbuild/extra-i686/root
# cp /etc/resolv.conf etc/
# cp $imgdir/test.jpg .
# rm /var/cache/pacman/pkg/{opencv,python2}*
# mount -o bind /var/cache/pacman/pkg var/cache/pacman/pkg
# chroot .
# pacman -Syu opencv python2-numpy
# python2
# import cv
# cv.LoadImageM('test.jpg', 1)

After you're done looking at the result:

# CTRL+D
# exit
# umount var/cache/pacman/pkg
# rm /etc/resolv.conf *.jpg

By now, I could close this as not being a bug and blame this on your system - but I won't be that arrogant. Instead, we're going to troubleshoot this if you're keen and patient:

1) pacman -Qlq opencv > opencv.pkglist
2) pacman -Syu python2 opencv
3) try
4) pacman -U the package at http://pkgbuild.com/~schiv/
5) try
6) rebuild opencv from ABS
7) try
8) report back here the results of (3), (5), (7) and attachment (1)

Btw, you find it suspicious that there is only a single python library, but:

* single import of all of OpenCV using "import cv"

From: http://opencv.willowgarage.com/wiki/PythonInterface

If you think that is insufficient, show us a filelist which you know to be sufficient (ask upstream; other distros).
Comment by Lazarus (Lazarus) - Thursday, 31 March 2011, 09:51 GMT
Not accusing you of incompetence. Was weary of being told to try cv.whatever even though I had already said cv.whatever doesn't get imported into my namespace through "import cv".

Then, again I was wrong in assuming that this package misses files in site-packages. SORRY ABOUT THAT.



In the chroot you described above, "import cv" does work correctly though ("dir(cv)" results in all the attributes being listed). Great.

However, it doesn't work in my real environment, even after going through hoops 1 to 8. Can't think of any other cause than that some package installed on my system conflicts with this one. Trying to narrow the culprit down by mimicking my real environment inside said chroot, but no luck so far...


Thank you for your kind help.
Comment by Lazarus (Lazarus) - Thursday, 31 March 2011, 09:57 GMT
BTW: can't post "opencv.pkglist" here, because it's around 10 MB in size.
Comment by Ray Rashif (schivmeister) - Thursday, 31 March 2011, 15:21 GMT
  • Field changed: Task Type (Feature Request → Bug Report)
  • Field changed: Summary ([opencv] Please compile opencv with python support → [opencv] python interface not responding)
  • Field changed: Severity (Low → Medium)
OK forget about the misunderstanding. Let's get to the point: it's not going to be trivial to figure out the root of the issue.

Right, install all the packages you have (instead of the foreign ones) to the chroot. You could also search and destroy previously self-made symlinks, foreign (non-package) libraries and libtool files in the system, but that would be tedious.

Sorry, it should've read:

pacman -Qlq opencv > opencv.pkglist

Please reinstall the base group like so:

pacman -S base

Make sure you're not using [testing], and reboot if possible. The final (desperate) solution would be this:

Reinstall Arch.

But of course, you only need access to another Linux system (not reinstall as in from a CD). From there, remove all packages except pacman and deps (backup the entire system package list if you want), remove leftovers in the system paths that do not look like they belong, then reinstall everything. You will need to follow https://wiki.archlinux.org/index.php/Install_From_Existing_Linux if you find yourself losing pacman/glibc/gcc-libs along the way.
Comment by Ray Rashif (schivmeister) - Monday, 04 April 2011, 08:11 GMT
Any progress? I'm not able to reproduce this however way I suspect. You might have some rogue symlinks.
Comment by Lazarus (Lazarus) - Tuesday, 05 April 2011, 08:39 GMT
I got around to a little testing today, and while I haven't gotten it exactly clear yet, the problem importing cv (and, as I found out now, other modules as well) is probably caused by python file(s) and/or director(y/ies) on the PYTHONPATH becoming inaccessible (e.g. when the user deletes such a directory) while a python interpreter instance is still running (or else at least while some kind of session is active). After that, importing of modules like cv apparently fails silently. Not entirely sure yet though... :V

Anyway, after rebooting or killing all python instances I can import cv successfully (at least sometimes...), so I think I can conclude that this problem is not caused by cv, so perhaps this bug report should be closed.

...sorry for the trouble.

Loading...