Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does cmake use Anaconda's Python?

I have been fighting some problems running OpenCV on Ubuntu 16.04. After some issues with unfound links and missing libraries warnings, I have realized OpenCV was looking for libraries in the path of Anaconda.

I have renamed the Anaconda folder, removed any reference of it from PATH, LDPATH, and PYHONPATH, and made sure I installed all necessary libraries on root.

As that was not enough, I received a suggestion to rebuild OpenCV. I went back to the OpenCV directory, entered a build folder, and ran cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local .., as suggested by OpenCV's installation guide. To my surprise, in the outcome I spotted these:

--   Python 2:
--     Interpreter:                 /usr/bin/python2.7 (ver 2.7.12)
--     Libraries:                   /usr/lib/x86_64-linux-gnu/libpython2.7.so (ver 2.7.12)
--     numpy:                       /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.11.0)
--     packages path:               lib/python2.7/dist-packages
-- 
--   Python 3:
--     Interpreter:                 /home/raggot/anaconda3/bin/python3 (ver 3.6.3)
-- 
--   Python (for build):            /usr/bin/python2.7
--     Pylint:                      /home/raggot/anaconda3/bin/pylint (ver: unknown, checks: 110)

and these:

--   Media I/O: 
--     ZLib:                        /home/raggot/anaconda3/lib/libz.so (ver )
--     JPEG:                        /home/raggot/anaconda3/lib/libjpeg.so (ver )
--     WEBP:                        build (ver encoder: 0x020e)
--     PNG:                         /home/raggot/anaconda3/lib/libpng.so (ver ..)
--     TIFF:                        /home/raggot/anaconda3/lib/libtiff.so (ver )
--     JPEG 2000:                   /home/raggot/anaconda3/lib/libjasper.so (ver )
--     OpenEXR:                     build (ver 1.7.1)
--     GDAL:                        NO
--     GDCM:                        NO

Is CMake telling that OpenCV will now refer to the /anaconda/ path for Python3 and some Media libraries? If so, how so? Where in my system are these links stored? How can I avoid OpenCV to refer to Anaconda?

like image 793
raggot Avatar asked Oct 14 '25 06:10

raggot


1 Answers

I solved it by analysing more into depth what CMake was actually assuming for all parameters I did not specify. By running

cmake-gui

and then searching for all fields containging anaconda I realised that for some reason CMake was using Anaconda's installation of Python3, and it was also finding the JPEG, TIFF, and PNG libraries of Anaconda.

As I had personally had many issues of this kind with Anaconda, and I personally didn't really need it for other projects, I just deleted Anaconda, and rebuilt OpenCV from scratch. Successfully this time.

like image 145
raggot Avatar answered Oct 16 '25 22:10

raggot



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!