I would like to use gtk-enabled opencv with python 3 inside of a nix-shell.
I am able to launch a non-gtk enabled python3/opencv environment with:
nix-shell --pure -p python35Packages.opencv3
However, commands that open windows fail:
[nix-shell:~/src/nixpkgs/pkgs/development/libraries/opencv]$ python
Python 3.5.3 (default, Jan 17 2017, 07:57:56)
[GCC 5.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.namedWindow("foo")
OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvNamedWindow, file /tmp/nix-build-opencv-3.2.0.drv-0/opencv-3.2.0-src/modules/highgui/src/window.cpp, line 565
In the package definition in /nixpkgs/pkgs/development/libraries/opencv/3.x.nix, there are function parameters enableGtk2 and enableGtk3 that switch on the optional dependency in the build.
I read through several nix tutorials and the entire syntax definition for the language.
Switching on an optional dependency is pretty fundamental, so I would expect it to be doable using the command-line tools, i.e. nix-shell. Anyone know how it is done?
This is the command that you would need to use in this case:
nix-shell -p "python35Packages.opencv3.override { enableGtk2 = true; }"
Another solution would be to override the python35Packages.opencv3 package once and for all as explained in the nixpkgs documentation. Then you would be able to use your command unchanged.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With