Installing OpenCV with Conda and Spyder
I’m having trouble installing OpenCV with Conda. I tried running numerous commands, none of which worked. For example, when I ran conda install -c anaconda opencv (as per https://anaconda.org/anaconda/opencv) I get this error:
UnsatisfiableError: The following specifications were found to be incompatible with the existing python installation in your environment: Specifications: - opencv -> python[version='>=2.7,<2.8.0a0|>=3.5,<3.6.0a0|>=3.6,<3.7.0a0|>=3.7,
Why is this happening and how can I install OpenCV in Spyder? Thanks.
asked Jul 31, 2020 at 17:16
Tejas_hooray Tejas_hooray
616 1 1 gold badge 6 6 silver badges 17 17 bronze badges
2 Answers 2
The answer for this issue is updating Anaconda to the newest version:
conda update -n base -c defaults conda
then you can install opencv normally using:
conda install -c conda-forge opencv
answered Oct 6, 2020 at 7:55
quangbk2010 quangbk2010
168 1 1 silver badge 6 6 bronze badges
Python 3.8 is relatively new. And according to the error it looks like that conda package manager still does not support Python 3.8.
Try downloading using this command:
pip install opencv-python
answered Jul 31, 2020 at 17:32
Shrey Shah Shrey Shah
109 5 5 bronze badges
Hi, I tried that, but when I do that I get this error in my Spyder console when I run my program: You might be loading two sets of Qt binaries into the same process. Check that all plugins are compiled against the right Qt binaries. Export DYLD_PRINT_LIBRARIES=1 and check that only one set of binaries are being loaded. QObject::moveToThread: Current thread (0x7fa116b51ec0) is not the object's thread (0x7fa116946910). Cannot move to target thread (0x7fa116b51ec0)
Jul 31, 2020 at 17:36
Also, it looks like on this site that Anaconda Navigator does support Python 3.8: anaconda.com/products/individual
Установка OpenCV-Python на виртуальной среде для суперчайников
Здесь вы найдете пошаговый пример установки библиотеки OpenCV на Python.
- Установка Python
- Установка виртуальной среды
- Установка OpenCV + jupiterlab, numpy, matplotlib
- Тестирование
Все тестировала на планшете Microsoft Surface, Windows 10 Pro, c 64-битной операционной системой.
Предположим, что на вашем устройстве ничего не установлено заранее.
- Сначала установим Python.
Скачиваем нужную версию и запускаем .exe файл. Не забываем установить галочку add path. Я установила Python 3.7.3 от 25 марта 2019 г., потому что новая на данный момент версия Python 3.7.4 от 8го июля 2019 г. работала некорректно, а именно в терминале некоторые команды зависали. Открываем командную строку. - Устанавливаем virtualenv.
Виртуальная среда нам нужна для того, чтобы для каждого отдельного проекта была своя "комната" со своими версиями установленных библиотек, которые не будут зависеть от других проектов и путаться между собой.
Пакеты будем устанавливать с помощью pip. Он в последнее время сразу идет с Python, но обычно требуется его обновить командой:
python -m pip install --upgrade pip
Обновили pip, теперь установим виртуальную среду:
pip install virtualenv
Командой cd перейдите в папку, в которой хотите создать среду и введите команду:
mkdir opencvtutorial_env — так мы создали среду с названием opencvtutorial_env.
Далее вводим команду virtualenv opencvtutorial_env и для активации перейдите в папку среды и далее с помощью Tab до activate.
.\opencvtutorial_env\Scripts\activate - Установим библиотеки OpenCV-Python, Numpy и Matplotlib, которые понадобятся для тестирования функций opencv.
Самый легкий и быстрый вариант установки у меня получился с неофициальной версии. Устанавливаем его командой:
pip install opencv-python
Вместе с opencv-python в подарок с этим пакетом идет numpy. Дополнительно установим matplotlib: pip install matplotlib . - Установим pip install jupyterlab и запустим его командой jupyter notebook .
Теперь осталось проверить все ли у нас работает. В открывшемся окне создаем новый Python 3 файл, и запускаем команду:
import cv2 as cv
print( cv.__version__ )
Если выходит версия opencv, то поздравляю, можно тестировать туториалы c официального сайта. Мои примеры работ по туториалам можно найти здесь.
- opencv-python
- computer vision
- компьютерное зрение
- python3
- virtualenv
Installation by Making Your Own Libraries from the Source Files
You may find the content of this tutorial also inside the following videos: Part 1 and Part 2, hosted on YouTube.
These videos above are long-obsolete and contain inaccurate information. Be careful, since solutions described in those videos are no longer supported and may even break your install.
If you are building your own libraries you can take the source files from our Git repository.
Building the OpenCV library from scratch requires a couple of tools installed beforehand:
- An IDE of choice (preferably), or just a CC++ compiler that will actually make the binary files. Here we will use the Microsoft Visual Studio. However, you can use any other IDE that has a valid CC++ compiler.
- CMake, which is a neat tool to make the project files (for your chosen IDE) from the OpenCV source files. It will also allow an easy configuration of the OpenCV build files, in order to make binary files that fits exactly to your needs.
- Git to acquire the OpenCV source files. A good tool for this is TortoiseGit. Alternatively, you can just download an archived version of the source files from our page on Sourceforge
OpenCV may come in multiple flavors. There is a "core" section that will work on its own. Nevertheless, there is a couple of tools, libraries made by 3rd parties that offer services of which the OpenCV may take advantage. These will improve its capabilities in many ways. In order to use any of them, you need to download and install them on your system.
- The Python libraries are required to build the Python interface of OpenCV. For now use the version 2.7. . This is also a must if you want to build the OpenCV documentation.
- Numpy is a scientific computing package for Python. Required for the Python interface.
- Intel Threading Building Blocks (TBB) is used inside OpenCV for parallel code snippets. Using this will make sure that the OpenCV library will take advantage of all the cores you have in your system's CPU.
- Intel Integrated Performance Primitives (IPP) may be used to improve the performance of color conversion, Haar training and DFT functions of the OpenCV library. Watch out, since this is not a free service.
- OpenCV offers a somewhat fancier and more useful graphical user interface, than the default one by using the Qt framework. For a quick overview of what this has to offer, look into the documentations highgui module, under the Qt New Functions section. Version 4.6 or later of the framework is required.
- Eigen is a C++ template library for linear algebra.
- The latest CUDA Toolkit will allow you to use the power lying inside your GPU. This will drastically improve performance for some algorithms (e.g the HOG descriptor). Getting more and more of our algorithms to work on the GPUs is a constant effort of the OpenCV team.
- OpenEXR source files are required for the library to work with this high dynamic range (HDR) image file format.
- The OpenNI Framework contains a set of open source APIs that provide support for natural interaction with devices via methods such as voice command recognition, hand gestures, and body motion tracking. Prebuilt binaries can be found here. The source code of OpenNI and OpenNI2 are also available on Github.
- Doxygen is a documentation generator and is the tool that will actually create the OpenCV documentation.
Now we will describe the steps to follow for a full build (using all the above frameworks, tools and libraries). If you do not need the support for some of these, you can just freely skip this section.
Building the library
- Make sure you have a working IDE with a valid compiler. In case of the Microsoft Visual Studio just install it and make sure it starts up.
- Install CMake. Simply follow the wizard, no need to add it to the path. The default install options are OK.
- Download and install an up-to-date version of msysgit from its official site. There is also the portable version, which you need only to unpack to get access to the console version of Git. Supposing that for some of us it could be quite enough.
- Install TortoiseGit. Choose the 32 or 64 bit version according to the type of OS you work in. While installing, locate your msysgit (if it does not do that automatically). Follow the wizard – the default options are OK for the most part.
- Choose a directory in your file system, where you will download the OpenCV libraries to. I recommend creating a new one that has short path and no special characters in it, for example D:/OpenCV . For this tutorial, I will suggest you do so. If you use your own path and know, what you are doing – it is OK.
- Clone the repository to the selected directory. After clicking Clone button, a window will appear where you can select from what repository you want to download source files (https://github.com/opencv/opencv.git) and to what directory ( D:/OpenCV ).
- Push the OK button and be patient as the repository is quite a heavy download. It will take some time depending on your Internet connection.


Extract it into a nice and short named directory like D:/OpenCV/dep/qt/ . Then you need to build it. Start up a Visual Studio Command Prompt (2010) by using the start menu search (or navigate through the start menu All Programs –> Microsoft Visual Studio 2010 –> Visual Studio Tools –> Visual Studio Command Prompt (2010)).

Now navigate to the extracted folder and enter inside it by using this console window. You should have a folder containing files like Install, Make and so on. Use the dir command to list files inside your current directory. Once arrived at this directory enter the following command:
configure.exe -release -no-webkit -no-phonon -no-phonon-backend -no-script -no-scripttools
-no-qt3support -no-multimedia -no-ltcgCompleting this will take around 10-20 minutes. Then enter the next command that will take a lot longer (can easily take even more than a full hour):
After this set the Qt environment variables using the following command on Windows 7:
setx -m QTDIR D:/OpenCV/dep/qt/qt-everywhere-opensource-src-4.7.3
Press the Configure button to specify the compiler (and IDE) you want to use. Note that in case you can choose between different compilers for making either 64 bit or 32 bit libraries. Select the one you use in your application development.

CMake will start out and based on your system variables will try to automatically locate as many packages as possible. You can modify the packages to use for the build in the WITH –> WITH_X menu points (where X is the package abbreviation). Here are a list of current packages you can turn on or off:

Select all the packages you want to use and press again the Configure button. For an easier overview of the build options make sure the Grouped option under the binary directory selection is turned on. For some of the packages CMake may not find all of the required files or directories. In case of these, CMake will throw an error in its output window (located at the bottom of the GUI) and set its field values to not found constants. For example:


For these you need to manually set the queried directories or files path. After this press again the Configure button to see if the value entered by you was accepted or not. Do this until all entries are good and you cannot see errors in the field/value or the output part of the GUI. Now I want to emphasize an option that you will definitely love: ENABLE –> ENABLE_SOLUTION_FOLDERS. OpenCV will create many-many projects and turning this option will make sure that they are categorized inside directories in the Solution Explorer. It is a must have feature, if you ask me.

- BUILD_DOCS -> It creates two projects for building the documentation of OpenCV (there will be a separate project for building the HTML and the PDF files). Note that these are not built together with the solution. You need to make an explicit build project command on these to do so.
- BUILD_EXAMPLES -> OpenCV comes with many example applications from which you may learn most of the libraries capabilities. This will also come handy to easily try out if OpenCV is fully functional on your computer.
- BUILD_PACKAGE -> Prior to version 2.3 with this you could build a project that will build an OpenCV installer. With this, you can easily install your OpenCV flavor on other systems. For the latest source files of OpenCV, it generates a new project that simply creates a zip archive with OpenCV sources.
- BUILD_SHARED_LIBS -> With this you can control to build DLL files (when turned on) or static library files (*.lib) otherwise.
- BUILD_TESTS -> Each module of OpenCV has a test project assigned to it. Building these test projects is also a good way to try out, that the modules work just as expected on your system too.
- BUILD_PERF_TESTS -> There are also performance tests for many OpenCV functions. If you are concerned about performance, build them and run.
- BUILD_opencv_python -> Self-explanatory. Create the binaries to use OpenCV from the Python language.
- BUILD_opencv_world -> Generate a single "opencv_world" binary (a shared or static library, depending on BUILD_SHARED_LIBS) including all the modules instead of a collection of separate binaries, one binary per module.
Press again the Configure button and ensure no errors are reported. If this is the case, you can tell CMake to create the project files by pushing the Generate button. Go to the build directory and open the created OpenCV solution. Depending on just how much of the above options you have selected the solution may contain quite a lot of projects so be tolerant on the IDE at the startup. Now you need to build both the Release and the Debug binaries. Use the drop-down menu on your IDE to change to another of these after building for one of them.

In the end, you can observe the built binary files inside the bin directory:

For the documentation, you need to explicitly issue the build commands on the doxygen project for the HTML documentation. It will call Doxygen to do all the hard work. You can find the generated documentation inside the build/doc/doxygen/html .
To collect the header and the binary files, that you will use during your own projects, into a separate directory (similarly to how the pre-built binaries ship) you need to explicitly build the Install project.

This will create an Install directory inside the Build one collecting all the built binaries into a single place. Use this only after you built both the Release and Debug versions.
To test your build just go into the Build/bin/Debug or Build/bin/Release directory and start a couple of applications like the contours.exe. If they run, you are done. Otherwise, something definitely went awfully wrong. In this case you should contact us at our Q&A forum. If everything is okay, the contours.exe output should resemble the following image (if built with Qt support):

Set the OpenCV environment variable and add it to the systems path
First, we set an environment variable to make our work easier. This will hold the build directory of our OpenCV library that we use in our projects. Start up a command window and enter:
Getting started¶
Open3D Python packages are distributed via PyPI.
Supported Python versions:
Supported operating systems:
- Ubuntu 18.04+
- macOS 10.15+
- Windows 10+ (64-bit)
If you have other Python versions or operating systems, please refer to Build from source and compile Open3D from source.
Pip (PyPI)¶
pip install open3d # or pip install open3d-cpu # Smaller CPU only wheel on x86_64 Linux (since v0.17+)
Please upgrade your pip to a version >=20.3 to install Open3D in Linux, e.g. with
pip install -U pip>=20.3
In general, we recommend using a virtual environment or conda environment. Otherwise, depending on the configurations, you may need pip3 for Python 3, or the --user option to avoid permission issues. For example:
pip3 install open3d # or pip install --user open3d # or python3 -m pip install --user open3d
Development version (pip)¶
To test the latest features in Open3D, download and install the development version ( HEAD of master branch):
Please use these links from the latest version of this page only. You can also install the latest development version directly with pip:
pip install --trusted-host www.open3d.org -f http://www.open3d.org/docs/latest/getting_started.html open3d
The development wheels for Linux are named according to PEP600. Please use pip version >=20.3 to install them. The wheels are not yet fully PEP600 compliant.
Try it¶
# Verify installation python -c "import open3d as o3d; print(o3d.__version__)" # Python API python -c "import open3d as o3d; \ mesh = o3d.geometry.TriangleMesh.create_sphere(); \ mesh.compute_vertex_normals(); \ o3d.visualization.draw(mesh, raw_mode=True)" # Open3D CLI open3d example visualization/draw
If everything works, congratulations, now Open3D has been successfully installed!
Troubleshooting:¶
If you get an error when importing Open3D, enable detailed Python warnings to help troubleshoot the issue:
python -W default -c "import open3d as o3d"Running Open3D tutorials¶
A complete set of Python tutorials and testing data will also be copied to demonstrate the usage of Open3D Python interface. See examples/python for all Python examples.
Open3D’s Python tutorial utilizes some external packages: numpy , matplotlib , opencv-python . OpenCV is only used for reconstruction system. Please read util/install-deps-python.sh for installing these packages.
C++¶
To get started with using Open3D in your C++ applications, you can download a binary package archive from Github releases (since v0.15 ). These binary package archives contain the Open3D shared library built with all supported features and are available for the main supported platforms. Also, the latest development version ( HEAD of master branch) binary package archives are provided here 1:
Please use these links from the latest version of this page only.
To check the glibc version on your system, run ldd --version .
In Linux, do not link code with different CXX11 ABIs, since this will most likely cause linker errors or crashes. Most system libraries in recent Linux versions (e.g. if the OS came with GCC versions 5+) use the CXX11 ABI, while PyTorch and Tensorflow libraries typically use the pre CXX11 ABI.
If you need a subset of features, or a custom build configuration, please refer to Build from source and compile Open3D from source.
Try it¶
Extract the archive and move the contents to a local folder (such as $HOME/Documents/Open3D_install ):
Linux / MacOSX: Windows: Open3D_install Open3D_install ├── include ├── bin │ └── open3d │ └── Open3D.dll │ ├── core ├── CMake │ ├── . │ ├── Open3DConfig.cmake │ ├── Open3DConfig.h │ ├── . │ ├── Open3D.h ├── include │ ├── . │ └── open3d └── lib │ ├── core ├── cmake │ ├── . │ └── Open3D │ ├── Open3DConfig.h │ ├── . │ ├── Open3D.h ├── libOpen3D.so │ ├── . ├── open3d_tf_ops.so └── lib └── open3d_torch_ops.so └── Open3D.lib
Some files may be absent in the case of unsupported functionality. To use Open3D with your programs through cmake , add -D Open3D_ROOT=$HOME/Documents/Open3D_install to your CMake configure command line. See the following example CMake projects for reference:
- Find Pre-Installed Open3D Package in CMake
- Use Open3D as a CMake External Project
The C++ code examples in the examples/cpp folder of the repository illustrate a lot of the functionality available in Open3D and are a good place to start using Open3D in your projects.
