I am unable to import cv2 with python, emerging opencv does not seem to install any python modules. ` [I] media-libs/opencv Available versions: 2.4.13-r3(0/2.4) 3.4.1-r7(0/3.4.1) (~)4.1.2-r1(0/4.1.2) (~)4.1.2-r2(0/4.1.2) {contrib contribcvv contribdnn contribhdf contribsfm contribxfeatures2d cuda debug dnnsamples -download +eigen examples +features2d ffmpeg gdal gflags glog gphoto2 gstreamer gtk ieee1394 java jpeg jpeg2k lapack libav opencl opencvapps openexr opengl openmp pch png +python qt5 tesseract testprograms threads tiff v4l vaapi vtk webp xine ABI_MIPS="n32 n64 o32" ABI_RISCV="lp64 lp64d" ABI_S390="32 64" ABI_X86="32 64 x32" CPU_FLAGS_X86="avx avx2 fma3 popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3" ELIBC="FreeBSD" PYTHON_SINGLE_TARGET="+python2_7" PYTHON_TARGETS="(+)python2_7 python3_5 python3_6 python3_7"} Installed versions: 4.1.2-r2(0/4.1.2)(17:24:33 23/12/19)(eigen features2d gstreamer gtk jpeg opengl openmp png python tiff -contrib -contribcvv -contribdnn -contribhdf -contribsfm -contribxfeatures2d -cuda -debug -dnnsamples -download -examples -ffmpeg -gdal -gflags -glog -gphoto2 -ieee1394 -java -jpeg2k -lapack -libav -opencl -opencvapps -openexr -pch -qt5 -tesseract -testprograms -threads -v4l -vaapi -vtk -webp -xine ABI_MIPS="-n32 -n64 -o32" ABI_RISCV="-lp64 -lp64d" ABI_S390="-32 -64" ABI_X86="64 -32 -x32" CPU_FLAGS_X86="sse sse2 -avx -avx2 -fma3 -popcnt -sse3 -sse4_1 -sse4_2 -ssse3" ELIBC="-FreeBSD" PYTHON_TARGETS="python2_7 python3_6 -python3_5 -python3_7") Homepage: https://opencv.org Description: A collection of algorithms and sample code for various computer vision problems ` ```` Python 3.6.9 (default, Nov 24 2019, 03:26:07) [GCC 8.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import cv2 Traceback (most recent call last): File "<stdin>", line 1, in <module> ModuleNotFoundError: No module named 'cv2' ```` Cv2 was working fine a week ago.
Thank you for the report. Please recompile and *attach* the logfiles and paste the emerge info as described on https://wiki.gentoo.org/wiki/Attach_the_logs_to_the_bug_ticket We need to have all information at hand before ticket assignment, so that the maintainer can look after it in one session with minimal number of callbacks. Please reopen this ticket (Status:unconfirmed) afterwards.
Created attachment 600604 [details] build log of emerge media-libs/opencv
emerge --info media-libs/opencv : Portage 2.3.81 (python 3.6.9-final-0, default/linux/amd64/17.1/desktop/gnome/systemd, gcc-8.3.0, glibc-2.30-r3, 5.3.11-gentoo x86_64) ================================================================= System Settings ================================================================= System uname: Linux-5.3.11-gentoo-x86_64-Intel-R-_Xeon-R-_CPU_E5-2630_v4_@_2.20GHz-with-gentoo-2.6 KiB Mem: 131926868 total, 10206280 free KiB Swap: 131071996 total, 129316348 free Timestamp of repository gentoo: Wed, 11 Dec 2019 16:00:01 +0000 Head commit of repository gentoo: 185c0c46a8e90f24117ab52c06be496e99a4591d Head commit of repository science: d7c83c94da820078b789db52bbcc9ac12d7538ef sh bash 5.0_p11 ld GNU ld (Gentoo 2.33.1 p1) 2.33.1 app-shells/bash: 5.0_p11::gentoo dev-java/java-config: 2.2.0-r4::gentoo dev-lang/perl: 5.30.1::gentoo dev-lang/python: 2.7.17::gentoo, 3.6.9::gentoo, 3.7.5-r1::gentoo dev-util/cmake: 3.16.1::gentoo sys-apps/baselayout: 2.6-r1::gentoo sys-apps/sandbox: 2.18::gentoo sys-devel/autoconf: 2.13-r1::gentoo, 2.69-r5::gentoo sys-devel/automake: 1.16.1-r2::gentoo sys-devel/binutils: 2.33.1::gentoo sys-devel/gcc: 8.3.0-r3::gentoo, 9.2.0-r2::gentoo sys-devel/gcc-config: 2.1::gentoo sys-devel/libtool: 2.4.6-r5::gentoo sys-devel/make: 4.2.1-r4::gentoo sys-kernel/linux-headers: 5.4::gentoo (virtual/os-headers) sys-libs/glibc: 2.30-r3::gentoo Repositories: gentoo location: /usr/portage sync-type: rsync sync-uri: rsync://rsync.gentoo.org/gentoo-portage priority: -1000 sync-rsync-verify-max-age: 24 sync-rsync-extra-opts: sync-rsync-verify-jobs: 1 sync-rsync-verify-metamanifest: yes science location: /var/lib/overlays/science sync-type: git sync-uri: git://git.gentoo.org/proj/sci.git masters: gentoo chymeric location: /home/chymera/src/overlay masters: gentoo priority: 8889 ACCEPT_KEYWORDS="amd64 ~amd64" ACCEPT_LICENSE="*" CBUILD="x86_64-pc-linux-gnu" CFLAGS="-march=native -O2 -pipe" CHOST="x86_64-pc-linux-gnu" CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt" CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c" CXXFLAGS="-march=native -O2 -pipe" DISTDIR="/usr/portage/distfiles" EMERGE_DEFAULT_OPTS="--keep-going" ENV_UNSET="DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR" FCFLAGS="-march=native -O2 -pipe" FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr" FFLAGS="-march=native -O2 -pipe" GENTOO_MIRRORS="http://distfiles.gentoo.org" LANG="en_GB.UTF-8" LDFLAGS="-Wl,-O1 -Wl,--as-needed" MAKEOPTS="-j20" PKGDIR="/usr/portage/packages" PORTAGE_CONFIGROOT="/" PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git" PORTAGE_TMPDIR="/var/tmp" USE="X a52 aac acl acpi alsa amd64 berkdb bluetooth branding bzip2 cairo cdda cli colord crypt cups cxx dbus dri dts dvd dvdr eds emboss encode evo exif fam fat flac fortran gdbm gif gnome gnome-keyring gnome-online-accounts gpm gstreamer gtk iconv icu introspection ipv6 jpeg latex lcms ldap libnotify libsecret libtirpc mad mng mp3 mp4 mpeg multilib nautilus ncurses networkmanager nls nptl ntfs ogg opengl openmp pam pango pcre pdf png policykit ppds pulseaudio python readline science sdl seccomp spell split-usr ssl startup-notification svg systemd tcpd tiff tracker truetype udev udisks unicode upower usb vorbis wxwidgets x264 xattr xcb xml xv xvid zlib" ABI_X86="64" ADA_TARGET="gnat_2018" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext sse sse2" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" GRUB_PLATFORMS="efi-64" INPUT_DEVICES="libinput keyboard mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" NETBEANS_MODULES="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-2" POSTGRES_TARGETS="postgres10 postgres11" PYTHON_SINGLE_TARGET="python3_6" PYTHON_TARGETS="python2_7 python3_6" RUBY_TARGETS="ruby24 ruby25" USERLAND="GNU" VIDEO_CARDS="nvidia" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account" Unset: CC, CPPFLAGS, CTARGET, CXX, INSTALL_MASK, LC_ALL, LINGUAS, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS ================================================================= Package Settings ================================================================= media-libs/opencv-4.1.2-r2::gentoo was built with the following: USE="eigen features2d gstreamer gtk jpeg opengl openmp png python tiff -contrib -contribcvv -contribdnn -contribhdf -contribsfm -contribxfeatures2d -cuda -debug -dnnsamples -download -examples -ffmpeg -gdal -gflags -glog -gphoto2 -ieee1394 -java -jpeg2k -lapack -libav -opencl -opencvapps -openexr -pch -qt5 -tesseract -testprograms -threads -v4l -vaapi -vtk -webp -xine" ABI_X86="(64) -32 (-x32)" CPU_FLAGS_X86="sse sse2 -avx -avx2 -fma3 -popcnt -sse3 -sse4_1 -sse4_2 -ssse3" PYTHON_TARGETS="python2_7 python3_6 -python3_5 -python3_7"
Created attachment 601900 [details, diff] opencv-4.1.2-python-lib-suffix-hack.patch
Both the ebuilds for opencv-4.1.2-r1 and 4.1.2-r2 seem to disable building python modules in multilib_src_configure() by appending these cmake arguments: -DBUILD_opencv_python2=OFF -DBUILD_opencv_python3=OFF Versions 2.4.13-r3 and 3.4.1-r7 are not affected since their ebuilds don't contain those lines. Commenting them fixed the issue for me, though I also had to apply the opencv-4.1.2-python-lib-suffix-hack.patch attached by Zitian Li for the modules to be installed to /usr/lib64 rather than /usr/lib.
Created attachment 604028 [details, diff] ebuild patch to re-enable the python modules
It's still there with 3.4.1-r7.
Created attachment 617586 [details, diff] Fix for opencv-3.4.1-r7 to build with python bindings This patch seems to fix the problem for me (opencv-3.4.1-r7)
I'm revisiting this ebuild and noticed a glaring mistake I had made last time, which was to accidentally disable the python USE flag for opencv, which caused the ebuild's python_module_compile() function not to run and therefore the python modules not to get built. Then, by hacking the cmake arguments in multilib_src_configure(), I caused them to be built and installed anyway, despite the missing USE flag. I apologize for polluting this bug report and ask that everyone please disregard my previous comment and patch.
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5c21b91ad2464439514aae406a0c0d5f310aca1d commit 5c21b91ad2464439514aae406a0c0d5f310aca1d Author: Ross Charles Campbell <rossbridger.cc@gmail.com> AuthorDate: 2020-10-14 02:17:02 +0000 Commit: Sam James <sam@gentoo.org> CommitDate: 2020-10-16 21:47:50 +0000 media-libs/opencv: version bump to 4.5.0 Bug: https://bugs.gentoo.org/701790 Bug: https://bugs.gentoo.org/700176 Bug: https://bugs.gentoo.org/717812 Bug: https://bugs.gentoo.org/703658 Bug: https://bugs.gentoo.org/689838 Closes: https://bugs.gentoo.org/666716 Closes: https://bugs.gentoo.org/747163 Closes: https://bugs.gentoo.org/729190 Closes: https://bugs.gentoo.org/699730 Closes: https://bugs.gentoo.org/672840 Package-Manager: Portage-3.0.8, Repoman-3.0.1 Signed-off-by: Ross Charles Campbell <rossbridger.cc@gmail.com> Closes: https://github.com/gentoo/gentoo/pull/17899 Signed-off-by: Sam James <sam@gentoo.org> media-libs/opencv/Manifest | 2 + media-libs/opencv/opencv-4.5.0.ebuild | 555 ++++++++++++++++++++++++++++++++++ 2 files changed, 557 insertions(+)
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e402fc2e336e59a514557c6c1bdb014cb590fad1 commit e402fc2e336e59a514557c6c1bdb014cb590fad1 Author: Ross Charles Campbell <rossbridger.cc@gmail.com> AuthorDate: 2020-12-24 06:05:46 +0000 Commit: Sam James <sam@gentoo.org> CommitDate: 2020-12-27 04:34:08 +0000 media-libs/opencv: version bump, remove old - Added constraint on CPU flags on x86 - Also closed out bugs that wasn't reported reproducible on newer versions Closes: https://bugs.gentoo.org/751781 Closes: https://bugs.gentoo.org/703658 Closes: https://bugs.gentoo.org/706040 Closes: https://bugs.gentoo.org/721706 Closes: https://bugs.gentoo.org/689838 Package-Manager: Portage-3.0.12, Repoman-3.0.2 Signed-off-by: Ross Charles Campbell <rossbridger.cc@gmail.com> Closes: https://github.com/gentoo/gentoo/pull/18801 Signed-off-by: Sam James <sam@gentoo.org> media-libs/opencv/Manifest | 4 ++-- ...{opencv-4.4.0-r1.ebuild => opencv-4.5.1.ebuild} | 26 +++++++++++++++------- 2 files changed, 20 insertions(+), 10 deletions(-)