Here is what I installed as described here:
1. Python 3.5 (Anaconda3 2.4.3)
Chainer 1.5.0.2
Cython 0.23.4
NumPy 1.10.1
tqdm
2. OpenCV 3.0.0
3. lmdb 0.87
4. Boost 1.59.0
Next I want to compile and install Boost.NumPy. In the beginning, NumPy module could not be found. After some search, I found NumPy-related files in ~/anaconda3/lib/python3.5/site-packages/numpy/core/include/numpy instead of something like /usr/lib, /usr/local/lib, etc. Therefore, in /Boost.NumPy/CMakeList.txt, I added this line:
set(NUMPY_INCLUDE_DIRS, /home/graphics/anaconda3/lib/python3.5/site-packages)
But NumPy still could not be found. An error occurred as I run cmake -DPYTHON_LIBRARY=$HOME/anaconda3/lib/libpython3.5m.so ../ to generate the makefile for Boost.NumPy. Here is the error:
graphics#gubuntu:~/usr/Boost.NumPy/build$ sudo cmake -DPYTHON_LIBRARY=$HOME/anaconda3/lib/libpython3.5m.so ../
-- The C compiler identification is GNU 4.9.2
-- The CXX compiler identification is GNU 4.9.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found PythonInterp: /usr/bin/python3.5 (found suitable version "3.5.1", minimum required is "3.5")
-- Found PythonInterp: /usr/bin/python3.5 (found version "3.5.1")
-- Found PythonLibs: /home/graphics/anaconda3/lib/libpython3.5m.so
CMake Error at libs/numpy/cmake/FindNumPy.cmake:61 (message):
NumPy import failure:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named 'numpy'
Call Stack (most recent call first):
CMakeLists.txt:30 (find_package)
-- Configuring incomplete, errors occurred!
I have tried to replace NUMPY_INCLUDE_DIRS with some other directories, but nothing works. What should I write to the CMakelists.txt to tell cmake where to find NumPy module and import it?
Thanks in advance!
Others files which might be needed to find out what goes wrong:
CMakeLists.txt of Boost.NumPy.
Finally it works! But I don't know why...:(
What I did:
1. I reinstalled numpy to /usr/lib/python3.5/site-packages (previously, I installed it to ~/anaconda3/lib/python3.4/site-packages)
1.1 I also added ~/anaconda3/lib/python3.4/site-packages/numpy/include to $PYTHONPATH and $PATH
2. I ran these commands in Python:
>>>import numpy
And I found it returns no error!
3. I removed previously compiled files in directory build, and rebuilt. Finally it worked
Hope these helps someone else.
Related
I want to make the compilation and distribution of a C++ program portable and simple using conda, so I've written a conda recipe. The build depends on some libraries to deal with image I/O, for example libpng and libtiff. The conda versions of these libraries are specified in the recipe, an excerpt is shown below:
requirements:
run_exports:
strong:
- libpng
- libtiff
- jpeg
- fftw
- eigen
host:
- {{ compiler('cxx') }}
- cmake
- python
- libpng
- libtiff
- jpeg
- fftw
- eigen
run:
- libtiff
- libpng
- jpeg
- fftw
my understanding is that host corresponds to the conda libraries used during compilation, while run and run_exports specify the libraries during runtime at the machine of the host or other machines.
On OS X, the cmake compilation runs normally, and in particular successfully compiles against the conda versions of the image libraries. An excerpt of the installation as takes place within the conda build . operation is shown below:
-- The C compiler identification is Clang 12.0.1
-- The CXX compiler identification is Clang 12.0.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: $PREFIX/bin/x86_64-apple-darwin13.4.0-clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: $PREFIX/bin/x86_64-apple-darwin13.4.0-clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenMP_C: -fopenmp=libomp (found version "5.0")
-- Found OpenMP_CXX: -fopenmp=libomp (found version "5.0")
-- Found OpenMP: TRUE (found version "5.0")
-- Found TIFF: $PREFIX/lib/libtiff.dylib (found version "4.0.9")
-- Found JPEG: $PREFIX/lib/libjpeg.dylib (found version "80")
-- Found ZLIB: $PREFIX/lib/libz.dylib (found version "1.2.11")
-- Found PNG: $PREFIX/lib/libpng.dylib (found version "1.4.12")
-- Configuring done
-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:
CMAKE_INSTALL_LIBDIR
CMAKE_LIBTOOL
-- Build files have been written to: $SRC_DIR/build
Scanning dependencies of target bm3d
[ 16%] Building CXX object CMakeFiles/bm3d.dir/bm3d.cpp.o
[ 33%] Building C object CMakeFiles/bm3d.dir/iio.c.o
[ 50%] Building CXX object CMakeFiles/bm3d.dir/lib_transforms.cpp.o
[ 66%] Building CXX object CMakeFiles/bm3d.dir/main.cpp.o
[ 83%] Building CXX object CMakeFiles/bm3d.dir/utilities.cpp.o
[100%] Linking CXX executable bm3d
[100%] Built target bm3d
Consolidate compiler generated dependencies of target bm3d
[100%] Built target bm3d
Install the project...
-- Install configuration: "Release"
-- Installing: $PREFIX/bin/bm3d
At the end of the conda building process, I then upload the package to the anaconda store, and install it (conda install -c efmkoene bm3d). But then upon testing, it turns out the executable is using a different set of libraries for the image I/O -- in my case causing trouble. An example of the program run against an image (e.g., bm3d ~/Downloads/example.png 10 out.png) gives
libpng warning: Application built with libpng-1.4.12 but running with 1.6.37
ERROR(""): png_create_read_struct fail
Note thus how the libpng on runtime (in this case, a result of brew install libpng) is not the same as the one used for the compilation, even though I am in the same runtime environment as the one used for the compilation. Is there a fix for this problem?
For future reference, the error was indeed in the cmake process detecting wrong info regarding libpng. Adding set(CMAKE_FIND_FRAMEWORK LAST) in the CMakeLists.txt fixed the issue! As reported at OSX + homebrew + CMake + libpng version mismatch issue by Kikaxa:
The problem is that classical cmake-style Find*.cmake search for the
headers and libraries separately - and the results MAY and WILL
mismatch in some cases. MacOS exaggerates the problem by having
special case of frameworks, being searched BEFORE other locations by
default.
On installing cmake in a build file
The command line prompts an error, shown in image 1 attached. After researching, it seems that the error is due to python (dependecies or filepath or any other problem). Showen below
On installing cmake and conan in a build file this is the out put command cmake -DGEN_CONAN_BUILD_INFO=ON -DCMAKE_BUILD_TYPE=Debug -DINSTALL_DEFAULT_CONF=ON -DINSTALL_EMPTY_SCHEMA_DB=ON ../
-- The CXX compiler identification is GNU 8.2.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Traceback (most recent call last):
File "/home/A/.local/bin/conan", line 6, in <module>
from conans.conan import run
ImportError: No module named conans.conan
CMake Error at CMakeLists.txt:7 (message):
Failed to conan install
-- Configuring incomplete, errors occurred!
See also "/home/A/Desktop/project/build/CMakeFiles/CMakeOutput.log"
enter image description here
On reinstalling or or purging python this is the output
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
gsettings-desktop-schemas : Breaks: mutter (< 3.31.4) but 3.30.2-4 is to be
installed
libc6-dev : Breaks: libgcc-8-dev (< 8.4.0-2~) but 8.2.0-14 is to be
installed
Breaks: python3.7 (< 3.7.7-1+b1) but 3.7.2-1 is to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by
held packages.
Good afternoon, help me please, I want to install dlib for python on windows, but when I write python.exe setup.py install in cmd in dlib dir or pip.exe install dlib I have this error:
CMake Warning at /usr/share/cmake-2.8.9/Modules/Platform/CYGWIN.cmake:15 (message):
CMake no longer defines WIN32 on Cygwin!
(1) If you are just trying to build this project, ignore this warning or
quiet it by setting CMAKE_LEGACY_CYGWIN_WIN32=0 in your environment or in
the CMake cache. If later configuration or build errors occur then this
project may have been written under the assumption that Cygwin is WIN32.
In that case, set CMAKE_LEGACY_CYGWIN_WIN32=1 instead.
(2) If you are developing this project, add the line
set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required
at the top of your top-level CMakeLists.txt file or set the minimum
required version of CMake to 2.8.4 or higher. Then teach your project to
build on Cygwin without WIN32.
Call Stack (most recent call first):
/usr/share/cmake-2.8.9/Modules/CMakeSystemSpecificInformation.cmake:36 (INCLUDE)
-- Check for working C compiler: /usr/bin/gcc.exe
-- Check for working C compiler: /usr/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++.exe
-- Check for working CXX compiler: /usr/bin/c++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
CMake Error at CMakeLists.txt:2 (CMAKE_MINIMUM_REQUIRED):
CMake 2.8.12 or higher is required. You are running version 2.8.9
-- Configuring incomplete, errors occurred!
error: cmake configuration failed!
I try to update cygwin's cmake with Cygwin installer, but setup.py use the old version of cmake (2.8.9). I try to run setup.py from cygwin's console, but it doesn't see a Boost (But it installed on my computer). I have this error in cygwin:
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++.exe
-- Check for working CXX compiler: /usr/bin/c++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Could NOT find Boost
CMake Error at /usr/share/cmake-3.3.2/Modules/FindPythonLibs.cmake:168 (file):
file STRINGS file
"/cygdrive/c/dlib-19.4/tools/python/C:/Python27/include/patchlevel.h"
cannot be read.
Call Stack (most recent call first):
/cygdrive/c/dlib-19.4/dlib/cmake_utils/add_python_module:75 (FIND_PACKAGE)
CMakeLists.txt:6 (include)
CMake Error at /usr/share/cmake- 3.3.2/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
Could NOT find PythonLibs: Found unsuitable version "", but required is at
least "2.6" (found C:/Python27/libs/python27.lib)
Call Stack (most recent call first):
/usr/share/cmake-3.3.2/Modules/FindPackageHandleStandardArgs.cmake:386 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-3.3.2/Modules/FindPythonLibs.cmake:205 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
/cygdrive/c/dlib-19.4/dlib/cmake_utils/add_python_module:75 (FIND_PACKAGE)
CMakeLists.txt:6 (include)
-- Configuring incomplete, errors occurred!
error: cmake configuration failed!
Can I update cygwin's cmake for using it in cmd or make the cygwin's terminal to see Boost?
If you have anaconda you can try this
conda install -c menpo dlib=18.18
I had a lot of problems, when I tried to install it with pip, but with anaconda it was ok
(Please, excuse my bad English!) Got into trap while trying to install dlib library on my computer(Windows 10 Pro, 64x), but all the time get the same error: Could NOT find Boost
What I have already done:
Installed Visual Studio Community 2017 version 15.1
Installed Anaconda: Python 3.6.0
|Anaconda 4.3.1 (64-bit)| (default, Dec 23 2016, 11:57:41) [MSC v.1900 64 bit (AMD64)] on win32
Downloaded boost_1_64_0.7z and unpacked it
Ran bootstrap
b2 -a --with-python address-model=64 toolset=msvc runtime-link=static
got the message: The Boost C++ Libraries were successfully built!
6.Next:
set BOOST_LIBRARYDIR=C:\Users\Lelek\boost_1_64_0\stage\lib
set BOOST_INCLUDEDIR=C:\Users\Lelek\boost_1_64_0
set BOOST_ROOT=C:\Users\Lelek\boost_1_64_0
set PATH=%PATH%;%BOOST_ROOT%;%BOOST_LIBRARYDIR%
7. On this stage if I try to run python setup.py install from dlib directory I get the output (the same error appears when try to call cmake -G "Visual Studio 15 2017 Win64" -DPYTHON3=1 .\tools\python):
CMake Warning at C:/Program Files/Cmake/share/cmake-3.8/Modules/FindBoost.cmake:1521 (message):
No header defined for python-py34; skipping header check
Call Stack (most recent call first):
C:/Users/Lelek/dlib-19.4/dlib/cmake_utils/add_python_module:61(FIND_PACKAGE)
CMakeLists.txt:6 (include)
-- Could NOT find Boost
CMake Warning at C:/Program Files/Cmake/share/cmake-3.8/Modules/FindBoost.cmake:1521 (message):
No header defined for python-py35; skipping header check
Call Stack (most recent call first):
C:/Users/Lelek/dlib-19.4/dlib/cmake_utils/add_python_module:63 (FIND_PACKAGE)
CMakeLists.txt:6 (include)
-- Could NOT find Boost
CMake Warning at C:/Program Files/Cmake/share/cmake-3.8/Modules/FindBoost.cmake:1521 (message):
No header defined for python3; skipping header check
Call Stack (most recent call first):
C:/Users/Lelek/dlib-19.4/dlib/cmake_utils/add_python_module:66 (FIND_PACKAGE)
CMakeLists.txt:6 (include)
-- Could NOT find Boost
-- Could NOT find Boost
-- Found PythonLibs: C:/ProgramData/Anaconda3/libs/python36.lib (found suitable version "3.6.0", minimum required is "3.4")
-- We couldn't find the right version of boost python. If you installed boost and you are still getting this error then you might have installed a version of boost that was compiled with a different version of visual studio than the one you are using. So you have to make sure that the version of visual studio is the same version that was used to compile the copy of boost you are using.
-- Set the BOOST_ROOT and BOOST_LIBRARYDIR environment variables before running cmake.
-- E.g. Something like this:
-- set BOOST_ROOT=C:\local\boost_1_57_0
-- set BOOST_LIBRARYDIR=C:\local\boost_1_57_0\stage\lib
--
-- You will also likely need to compile boost yourself rather than using one of the precompiled
-- windows binaries. Do this by going to the folder tools\build\ within boost and running
-- bootstrap.bat. Then run the command:
-- b2 install
-- And then add the output bin folder to your PATH. Usually this is the C:\boost-build-engine\bin
-- folder. Finally, go to the boost root and run a command like this:
-- b2 -a --with-python address-model=64 toolset=msvc runtime-link=static
-- When it completes, set BOOST_LIBRARYDIR equal to wherever b2 put the compiled libraries.
-- Note that you will need to set the address-model based on if you want a 32 or 64bit python library.
--
-- Next, when you invoke cmake to compile dlib you may have to use cmake's -G option to set the
-- 64 vs. 32bit mode of visual studio. Also, if you want a Python3 library you will need to
-- add -DPYTHON3=1. You do this with a statement like:
-- cmake -G "Visual Studio 12 2013 Win64" -DPYTHON3=1 ..\..\tools\python
-- Rather than:
-- cmake ..\..\tools\python
-- Which will build a 32bit Python2 module by default on most systems.
--
--
CMake Error at C:/Users/Lelek/dlib-19.4/dlib/cmake_utils/add_python_module:116 (message):
Boost python library not found.
Call Stack (most recent call first):
CMakeLists.txt:6 (include)
-- Configuring incomplete, errors occurred!
See also "C:/Users/Lelek/dlib-19.4/tools/python/build/CMakeFiles/CMakeOutput.log".
error: cmake configuration failed!
As usual for me, I found the answer, as soon as I asked question. So, if someone will get the same issue:
To solve his problem I deleted Anaconda and installed only Python(3.5.0). Then updated dlib using PyCharm. And again, excuse my bad English, please.
If anyone still has this problem, try changing all calls to FIND_PACKAGE inside dlib\cmake_utils\add_python_module from 'Boost' to 'boost'. Worked for me.
If, after finding boost, the installation tries to open python27.lib and fails:
Remove boost.
Repeat steps 2--6 from the original question AFTER activating your py36 environment in Anaconda.
Re-run the dlib setup.
The latter was a stupid mistake of mine, but just in case.
I'm trying to install Python-OpenCV in Python3 on my LTS system following this guide.
When I try to run CMake:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D INSTALL_PYTHON_EXAMPLES=ON -D INSTALL_C_EXAMPLES=OFF -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.1.0/modules -D PYTHON_EXECUTABLE=~/.virtualenvs/cv/bin/python -D BUILD_EXAMPLES=ON ..
I get the following error:
-- Detected version of GNU GCC: 54 (504)
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found suitable version "1.2.8", minimum required is "1.2.3")
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.8")
-- Checking for module 'gstreamer-base-1.0'
-- No package 'gstreamer-base-1.0' found
-- Checking for module 'gstreamer-video-1.0'
-- No package 'gstreamer-video-1.0' found
-- Checking for module 'gstreamer-app-1.0'
-- No package 'gstreamer-app-1.0' found
-- Checking for module 'gstreamer-riff-1.0'
-- No package 'gstreamer-riff-1.0' found
-- Checking for module 'gstreamer-pbutils-1.0'
-- No package 'gstreamer-pbutils-1.0' found
-- Checking for module 'gstreamer-base-0.10'
-- No package 'gstreamer-base-0.10' found
-- Checking for module 'gstreamer-video-0.10'
-- No package 'gstreamer-video-0.10' found
-- Checking for module 'gstreamer-app-0.10'
-- No package 'gstreamer-app-0.10' found
-- Checking for module 'gstreamer-riff-0.10'
-- No package 'gstreamer-riff-0.10' found
-- Checking for module 'gstreamer-pbutils-0.10'
-- No package 'gstreamer-pbutils-0.10' found
-- Checking for module 'libdc1394-2'
-- No package 'libdc1394-2' found
-- Checking for module 'libdc1394'
-- No package 'libdc1394' found
-- Looking for linux/videodev.h
-- Looking for linux/videodev.h - not found
-- Looking for linux/videodev2.h
-- Looking for linux/videodev2.h - found
-- Looking for sys/videoio.h
-- Looking for sys/videoio.h - not found
-- Checking for module 'libavresample'
-- No package 'libavresample' found
-- Looking for libavformat/avformat.h
-- Looking for libavformat/avformat.h - found
-- Looking for ffmpeg/avformat.h
-- Looking for ffmpeg/avformat.h - not found
-- Checking for module 'libgphoto2'
-- No package 'libgphoto2' found
-- found IPP (ICV version): 9.0.1 [9.0.1]
-- at: /home/matt/opencv-3.1.0/3rdparty/ippicv/unpack/ippicv_lnx
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-- To enable PlantUML support, set PLANTUML_JAR environment variable or pass -DPLANTUML_JAR=<filepath> option to cmake
-- Found PythonInterp: /home/matt/.virtualenvs/cv/bin/python (found suitable version "3.5.2", minimum required is "2.7")
-- Found PythonInterp: /home/matt/.virtualenvs/cv/bin/python3 (found suitable version "3.5.2", minimum required is "3.4")
-- Could NOT find JNI (missing: JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)
-- Could NOT find Matlab (missing: MATLAB_MEX_SCRIPT MATLAB_INCLUDE_DIRS MATLAB_ROOT_DIR MATLAB_LIBRARIES MATLAB_LIBRARY_DIRS MATLAB_MEXEXT MATLAB_ARCH MATLAB_BIN)
CMake Error at /usr/local/lib/cmake/vtk-7.1/vtkModuleAPI.cmake:120 (message):
Requested modules not available:
vtkRenderingOpenGL
Call Stack (most recent call first):
/usr/local/lib/cmake/vtk-7.1/VTKConfig.cmake:89 (vtk_module_config)
cmake/OpenCVDetectVTK.cmake:6 (find_package)
CMakeLists.txt:597 (include)
-- Configuring incomplete, errors occurred!
See also "/home/matt/opencv-3.1.0/build/CMakeFiles/CMakeOutput.log".
See also "/home/matt/opencv-3.1.0/build/CMakeFiles/CMakeError.log".
I've followed the guide completely up until this point so I'm not sure what is wrong.
I've looked around to try and fix the missing package vtkRenderingOpenGL and followed this post.
I'm sure that I've installed this in the past and so unsurprisingly I get:
sudo apt -y install freeglut3-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
freeglut3-dev is already the newest version (2.8.1-2).
0 to upgrade, 0 to newly install, 0 to remove and 1 not to upgrade.
Any and all help is much appreciated!
Taking advice given from the OpenCV community forum (post).
Add this to CMake options:
-D WITH_VTK=OFF -D BUILD_opencv_viz=OFF
"opencv_viz is the only opencv module, that depends on vtk, and you cannot use it from python"
Therefore it is fine to just disable it all together and after doing so CMake completes.
My advice is: uninstall your ffmpeg and install an older one. For me, I installed opencv3.2.0 with ffmpeg4.0, and I got the error:
'No package 'libavresample' found'
and so on. Now, I change my ffmpeg to ffmpeg2.7.2, and it works for me.