Trouble with control module .statespace .pzmap - python

I calculate the zeros and poles of a system with control.StateSpace. In the following I want to use control.pzmap to display the result but the last doesn´t work. I can print sys and it seems okay but not as parameter of control.pzmap.
Can someone pls help me?
import numpy as np
import control
from OMPython import ModelicaSystem
import matplotlib.pyplot as plt
from help_fkt import delete_OM_files
#from numpy import pi as pi
L=0.1
R=80
C=3.3e-6
A= [[0,1/C],
[-1/L, -R/L]]
B=[[0],[1/L]]
C=[[1,0],[0,1],[-1,0]]
D= [[0],[0],[1]]
print(A)
print(B)
print(C)
print(D)
fig=plt.figure(1, figsize=(10,6)); fig.clf()
plt.show()
sys=control.StateSpace(A,B,C,D) #calculation of poles and zeros of the given system
print(sys)
a=sys.pole()
print(a)
control.pzmap(sys) #should make a diagram of poles and zeros, but doesn't work
plt.grid()
This is the error:
File "C:\anaconda3\envs\modsim\lib\site-packages\control\statesp.py",
line 575, in zero
from slycot import ab08nd
ModuleNotFoundError: No module named 'slycot'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File
"C:\Users\johan\OneDrive\Desktop\Studium\SimulationundModellbildung\Lösungen\LSG_Carlos\A7.py",
line 44, in
control.pzmap(sys)
File "C:\anaconda3\envs\modsim\lib\site-packages\control\pzmap.py",
line 91, in pzmap
zeros = sys.zero()
File
"C:\anaconda3\envs\modsim\lib\site-packages\control\statesp.py", line
587, in zero
raise NotImplementedError("StateSpace.zero only supports "
NotImplementedError: StateSpace.zero only supports systems with the same number of inputs as outputs.
Error when I try to install slycot:
(base) C:\Users\johan>pip install slycot Collecting slycot Using cached slycot-0.4.0.0.tar.gz (1.5 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing wheel metadata ... done Requirement already satisfied: numpy in c:\anaconda3\lib\site-packages (from slycot) (1.18.1) Building wheels for collected packages: slycot Building wheel for slycot (PEP 517) ... error ERROR: Command errored out with exit status 1: command: 'c:\anaconda3\python.exe' 'c:\anaconda3\lib\site-packages\pip_vendor\pep517_in_process.py' build_wheel 'C:\Users\johan\AppData\Local\Temp\tmpsxxs_crf' cwd: C:\Users\johan\AppData\Local\Temp\pip-install-r2r2i4rs\slycot Complete output (56 lines): Not searching for unused variables given on the command line. -- The C compiler identification is unknown CMake Error at CMakeLists.txt:3 (ENABLE_LANGUAGE): The CMAKE_C_COMPILER: cl is not a full path and was not found in the PATH. To use the NMake generator with Visual C++, cmake must be run from a shell that can use the compiler cl from the command line. This environment is unable to invoke the cl compiler. To fix this problem, run cmake from the Visual Studio Command Prompt (vcvarsall.bat). Tell CMake where to find the compiler by setting either the environment variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to the compiler, or to the compiler name if it is in the PATH. -- Configuring incomplete, errors occurred! See also "C:/Users/johan/AppData/Local/Temp/pip-install-r2r2i4rs/slycot/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log". See also "C:/Users/johan/AppData/Local/Temp/pip-install-r2r2i4rs/slycot/_cmake_test_compile/build/CMakeFiles/CMakeError.log". FC ('-DCMAKE_Fortran_COMPILER=', 'c:/anaconda3/Library/bin/flang.exe') F2PY ('-DF2PY_EXECUTABLE=', 'c:/anaconda3/Scripts/f2py.exe') NUMPY_INCLUDE ('-DNumPy_INCLUDE_DIR=', 'c:/anaconda3/Include') ['-DSLYCOT_VERSION:STRING=0.4.0', '-DGIT_REVISION:STRING=ac0944b363a6cfcc0c3d5128cdd484d74173aa3b', '-DISRELEASE:STRING=True', '-DFULL_VERSION=0.4.0.gitac0944b', '-GNMake Makefiles', '-DCMAKE_Fortran_COMPILER=c:/anaconda3/Library/bin/flang.exe', '-DF2PY_EXECUTABLE=c:/anaconda3/Scripts/f2py.exe', '-DNumPy_INCLUDE_DIR=c:/anaconda3/Include', '-DCMAKE_Fortran_SIMULATE_VERSION=5.0.0', '-DCMAKE_Fortran_COMPILER_ID=Flang', '-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON'] -------------------------------------------------------------------------------- -- Trying "NMake Makefiles (Visual Studio 15 2017 Win64 v141)" generator -------------------------------- --------------------------- ---------------------- ----------------- ------------ ------- -- -- ------- ------------ ----------------- ---------------------- --------------------------- -------------------------------- -- Trying "NMake Makefiles (Visual Studio 15 2017 Win64 v141)" generator - failure -------------------------------------------------------------------------------- ******************************************************************************** scikit-build could not get a working generator for your system. Aborting build. Building windows wheels for Python 3.7 requires Microsoft Visual Studio 2017. Get it with "Visual Studio 2017": https://visualstudio.microsoft.com/vs/ ******************************************************************************** ---------------------------------------- ERROR: Failed building wheel for slycot Failed to build slycot ERROR: Could not build wheels for slycot which use PEP 517 and cannot be installed directly WARNING: You are using pip version 20.2.4; however, version 20.3.3 is available. You should consider upgrading via the 'c:\anaconda3\python.exe -m pip install --upgrade pip' command.

Ok, I've installed anaconda environment (just for you ;) ) to pinpoint the problem. It seems thats not just your machine and using the package that you use is a little difficult then trivial.
It seems that you have two problems.
First problem is, one of the packages you use depends on slycot. But slycot requires some compiling work on the background in order to install itself. Compiling the files on your pc requires having a compiler installed on your computer. Preferred compiler for this package is Visual Studio 2017. If you check the error message carefully, it is asking you to download and install it from this page.
Second problem is something I am not familiar with. It is complaining that the input space has to be the same size with the output space.
NotImplementedError: StateSpace.zero only supports systems with the same number of inputs as outputs.
But then again, this might be caused by the first problem.
So, let's install the VS 2017 first and see if that resolves it. If not, we'll see if anything has changed and proceed from there.

Related

How to fix errors occurring on installation of Jupyter Notebook

I am new to Python and try to install Jupyter Notebook from within a Windows command prompt window using:
pip install jupyter
But after a couple of minutes of downloading, an error message is displayed as shown below:
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... error
ERROR: Command errored out with exit status 1:
command: 'c:\users\asd\appdata\local\programs\python\python38-32\python.exe
' 'c:\users\asd\appdata\local\programs\python\python38-32\lib\site-packages\pip\
_vendor\pep517\_in_process.py' prepare_metadata_for_build_wheel 'C:\Users\asd\Ap
pData\Local\Temp\tmpnj_hhq6y'
cwd: C:\Users\asd\AppData\Local\Temp\pip-install-_pnki5r8\pywinpty
Complete output (6 lines):
Cargo, the Rust package manager, is not installed or is not on PATH.
This package requires Rust and Cargo to compile extensions. Install it through
the system's package manager or via https://rustup.rs/
Checking for Rust toolchain....
----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\asd\appdata\local\progr
ams\python\python38-32\python.exe' 'c:\users\asd\appdata\local\programs\python\p
ython38-32\lib\site-packages\pip\_vendor\pep517\_in_process.py' prepare_metadata
_for_build_wheel 'C:\Users\asd\AppData\Local\Temp\tmpnj_hhq6y' Check the logs for
full command output.
WARNING: You are using pip version 20.2.1; however, version 21.1 is available.
You should consider upgrading via the 'c:\users\asd\appdata\local\programs\pytho
n\python38-32\python.exe -m pip install --upgrade pip' command.
I have attached here just the last part of the error output.
How to fix this error for a successful installation of Jupyter Notebook?
EDIT1: I installed the Rust package from the link in the error message. After that I tried installing Jupyter Notebook once again, and this time after proceeding a few steps further than before, it output another error:
Building wheels for collected packages: pywinpty
Building wheel for pywinpty (PEP 517) ... - WARNING: Subprocess output does
not appear to be encoded as cp1252
WARNING: Subprocess output does not appear to be encoded as cp1252
error
ERROR: Command errored out with exit status 1:
command: 'c:\users\asd\appdata\local\programs\python\python38-32\python.exe'
'c:\users\asd\appdata\local\programs\python\python38-32\lib\site-packages\pip\_v
endor\pep517\_in_process.py' build_wheel 'C:\Users\asd\AppData\Local\Temp\tmpaj5
u66_y'
cwd: C:\Users\asd\AppData\Local\Temp\pip-install-mep4ye8d\pywinpty
Complete output (60 lines):
Running `maturin pep517 build-wheel -i c:\users\asd\appdata\local\programs\pyt
hon\python38-32\python.exe`
Compiling proc-macro2 v1.0.26
Compiling unicode-xid v0.2.2
Compiling syn v1.0.71
Compiling winapi v0.3.9
Compiling jobserver v0.1.22
error: could not compile `proc-macro2`
To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed
dY'¥ maturin failed
Caused by: Failed to build a native library through cargo
Caused by: Cargo build finished with "exit code: 101": `cargo rustc --messag
e-format json --manifest-path Cargo.toml --release --lib --`
dY\x8d1 Building a mixed python/rust project
dY"- Found pyo3 bindings
dY\x90\x8d Found CPython 3.8 at c:\users\asd\appdata\local\programs\python\pyt
hon38-32\python.exe
error: linker `link.exe` not found
|
= note: The system cannot find the file specified. (os error 2)
note: the msvc targets depend on the msvc linker but `link.exe` was not found
note: please ensure that VS 2013, VS 2015, VS 2017 or VS 2019 was installed wi
th the Visual C++ option
error: aborting due to previous error
error: linker `link.exe` not found
|
= note: The system cannot find the file specified. (os error 2)
note: the msvc targets depend on the msvc linker but `link.exe` was not found
note: please ensure that VS 2013, VS 2015, VS 2017 or VS 2019 was installed wi
th the Visual C++ option
error: aborting due to previous error
error: linker `link.exe` not found
|
= note: The system cannot find the file specified. (os error 2)
note: the msvc targets depend on the msvc linker but `link.exe` was not found
note: please ensure that VS 2013, VS 2015, VS 2017 or VS 2019 was installed wi
th the Visual C++ option
error: aborting due to previous error
Error: command ['maturin', 'pep517', 'build-wheel', '-i', 'c:\\users\\asd\\app
data\\local\\programs\\python\\python38-32\\python.exe'] returned non-zero exit
status 1
----------------------------------------
ERROR: Failed building wheel for pywinpty
Failed to build pywinpty
ERROR: Could not build wheels for pywinpty which use PEP 517 and cannot be insta
lled directly
WARNING: You are using pip version 20.2.1; however, version 21.1 is available.
You should consider upgrading via the 'c:\users\asd\appdata\local\programs\pytho
n\python38-32\python.exe -m pip install --upgrade pip' command.
Upgrade your pip first:
pip install --upgrade pip
Then:
pip install jupyter
I'reached this post after failing to install notebook on a 32-bit python 3.8.3 execution. And as far as I found, pywinpty, which is a dependence, does not support 32-bit executions (see sources below).
I solved the problem by installing python on its 64-bit version.
Sources:
How do I determine if my python shell is executing in 32bit or 64bit?
pip install fails on Python 3.8 32-bit, prevents Jupyter install #129 which simply says that wheels cannot be installed with 32 bit Python and that you should use 64 bit Python instead.
We can't generate 32 bit wheels, sorry. Please use a 64bit build of Python.. Was not my case but might be useful this similar issue when using python 3.8 64-bit
Error installing Jupyter & pywinpty (Python)
https://github.com/spyder-ide/pywinpty/issues/123
Do
pip install wheel
and try again. It worked for me.
What to do:
Check if your python is 64-bit version. If no, go to python site (for example, here is the link to download 3.7.9. Just click at the version that has label "for AMD64/EM64T/x64", do it with any version you wish, just I don't like to use the newest version). Remove yours (with the uninstall file) and download this. Don't forget to put the checkmark near "Add PATH" below;
Download Rust (the description is inside) - you need some files. Check the PATHs - if you want to change them, do it (the names of the variables and where they are - both are written, you can search in the Internet how to change PATH var's (for example));
Go to Windows Shell with admin mode (Win+X and you get the field) - here is the most comfortable place to work;
Go to your python.exe (for example, my way is C:\Users\user\AppData\Local\Programs\Python\Python37) - just for sure;
python.exe python -m pip install --upgrade pip;
python.exe pip install jupyter;
If an error was returned that contains the missing of wheel, try to download it: python.exe pip install wheel.
Donwload any library you miss during installation and continue since the step you stopped at.
Try using Anaconda. link to install conda https://www.anaconda.com/products/individual
then cmd : conda install numpy
cmd: conda install jupyter
cmd : jupyter notebook
The error message looks quite clear, you needs to install Cargo via https://rustup.rs/
I have faced the same issue when I'm using vscode. The simplest solution is to use conda instead of pip
conda install jupyterlab

Could not build wheels for opencv-python which use PEP 517 and cannot be installed directly

I am trying to install opencv-python on windows but after running the pip install opencv-python command I keep geting the following error: ERROR: Could not build wheels for opencv-python which use PEP 517 and cannot be installed directly.
I'm using python version 3.9.0 and pip version pip 20.2.4.
I've tried upgrading both my pip version as well as running pip install --upgrade pip setuptools wheel, as found on similar threads, but none of these seems to solve the issue.
The full console output after running the command:
Collecting opencv-python
Downloading opencv-python-4.4.0.44.tar.gz (88.9 MB)
|████████████████████████████████| 88.9 MB 3.3 MB/s
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Collecting numpy>=1.17.3
Downloading numpy-1.19.2.zip (7.3 MB)
|████████████████████████████████| 7.3 MB 6.4 MB/s
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Building wheels for collected packages: opencv-python, numpy
Building wheel for opencv-python (PEP 517) ... error
ERROR: Command errored out with exit status 1:
command: 'c:\users\david\appdata\local\programs\python\python39\python.exe' 'c:\users\david\appdata\local\programs\python\python39\lib\site-packages\pip\_vendor\pep517\_in_process.py' build_wheel 'C:\Users\David\AppData\Local\Temp\tmpl1finc77'
cwd: C:\Users\David\AppData\Local\Temp\pip-install-gfwb0hqn\opencv-python
Complete output (153 lines):
Not searching for unused variables given on the command line.
CMake Error: CMake was unable to find a build program corresponding to "Ninja". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
-- Configuring incomplete, errors occurred!
See also "C:/Users/David/AppData/Local/Temp/pip-install-gfwb0hqn/opencv-python/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
Not searching for unused variables given on the command line.
CMake Error at CMakeLists.txt:2 (PROJECT):
Generator
Visual Studio 15 2017 Win64
could not find any instance of Visual Studio.
-- Configuring incomplete, errors occurred!
See also "C:/Users/David/AppData/Local/Temp/pip-install-gfwb0hqn/opencv-python/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
Not searching for unused variables given on the command line.
-- The C compiler identification is unknown
CMake Error at CMakeLists.txt:3 (ENABLE_LANGUAGE):
The CMAKE_C_COMPILER:
cl
is not a full path and was not found in the PATH.
To use the NMake generator with Visual C++, cmake must be run from a shell
that can use the compiler cl from the command line. This environment is
unable to invoke the cl compiler. To fix this problem, run cmake from the
Visual Studio Command Prompt (vcvarsall.bat).
Tell CMake where to find the compiler by setting either the environment
variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH.
-- Configuring incomplete, errors occurred!
See also "C:/Users/David/AppData/Local/Temp/pip-install-gfwb0hqn/opencv-python/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/David/AppData/Local/Temp/pip-install-gfwb0hqn/opencv-python/_cmake_test_compile/build/CMakeFiles/CMakeError.log".
Not searching for unused variables given on the command line.
-- The C compiler identification is unknown
CMake Error at CMakeLists.txt:3 (ENABLE_LANGUAGE):
The CMAKE_C_COMPILER:
cl
is not a full path and was not found in the PATH.
To use the JOM generator with Visual C++, cmake must be run from a shell
that can use the compiler cl from the command line. This environment is
unable to invoke the cl compiler. To fix this problem, run cmake from the
Visual Studio Command Prompt (vcvarsall.bat).
Tell CMake where to find the compiler by setting either the environment
variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH.
-- Configuring incomplete, errors occurred!
See also "C:/Users/David/AppData/Local/Temp/pip-install-gfwb0hqn/opencv-python/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/David/AppData/Local/Temp/pip-install-gfwb0hqn/opencv-python/_cmake_test_compile/build/CMakeFiles/CMakeError.log".
--------------------------------------------------------------------------------
-- Trying "Ninja (Visual Studio 15 2017 Win64 v141)" generator
--------------------------------
---------------------------
----------------------
-----------------
------------
-------
--
--
-------
------------
-----------------
----------------------
---------------------------
--------------------------------
-- Trying "Ninja (Visual Studio 15 2017 Win64 v141)" generator - failure
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Trying "Visual Studio 15 2017 Win64 v141" generator
--------------------------------
---------------------------
----------------------
-----------------
------------
-------
--
--
-------
------------
-----------------
----------------------
---------------------------
--------------------------------
-- Trying "Visual Studio 15 2017 Win64 v141" generator - failure
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Trying "NMake Makefiles (Visual Studio 15 2017 Win64 v141)" generator
--------------------------------
---------------------------
----------------------
-----------------
------------
-------
--
--
-------
------------
-----------------
----------------------
---------------------------
--------------------------------
-- Trying "NMake Makefiles (Visual Studio 15 2017 Win64 v141)" generator - failure
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Trying "NMake Makefiles JOM (Visual Studio 15 2017 Win64 v141)" generator
--------------------------------
---------------------------
----------------------
-----------------
------------
-------
--
--
-------
------------
-----------------
----------------------
---------------------------
--------------------------------
-- Trying "NMake Makefiles JOM (Visual Studio 15 2017 Win64 v141)" generator - failure
--------------------------------------------------------------------------------
********************************************************************************
scikit-build could not get a working generator for your system. Aborting build.
Building windows wheels for Python 3.9 requires Microsoft Visual Studio 2017.
Get it with "Visual Studio 2017":
https://visualstudio.microsoft.com/vs/
********************************************************************************
----------------------------------------
ERROR: Failed building wheel for opencv-python
Building wheel for numpy (PEP 517) ... done
Created wheel for numpy: filename=numpy-1.19.2-cp39-cp39-win_amd64.whl size=4816060 sha256=18bd09a9c5e107a2e44f8466057d0b423a244fb84949a6d5a6d88534a58e1e4a
Stored in directory: C:\Users\David\AppData\Local\Temp\pip-ephem-wheel-cache-v6mmdzxn\wheels\a3\17\dd\f2dba23a35bb6008732772ccfb13d3d0e537fbc6919ce6862b
Successfully built numpy
Failed to build opencv-python
ERROR: Could not build wheels for opencv-python which use PEP 517 and cannot be installed directly
Any kind of help would be appreciated, thanks!
There are no pre-built Python 3.9 binary wheels yet for opencv-python. To compile from source, you must install build tools (Visual Studio 15 2017) as indicated by the error:
scikit-build could not get a working generator for your system. Aborting build.
Building windows wheels for Python 3.9 requires Microsoft Visual Studio 2017.
Get it with "Visual Studio 2017":
https://visualstudio.microsoft.com/vs/
opencv-python Python 3.9 wheel tracking issue: https://github.com/skvark/opencv-python/issues/382

ERROR: Could not build wheels for opencv-python which use PEP 517 and cannot be installed directly (cl was not found in PATH)

I was trying to install opencv-python in visual studio (with Visual Studio 2019 installed) but kept coming up with this error. I have tried most of the methods that were previously posted regarding this PEP517 error but i am still getting errors. Appreciate if someone could help me out here as i am just a beginner coder. Thanks alot in advance.
Below is the error code:
$ pip install opencv-python
Collecting opencv-python
Using cached opencv-python-4.4.0.44.tar.gz (88.9 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Requirement already satisfied: numpy>=1.17.3 in c:\python\lib\site-packages (from opencv-python) (1.19.2)
Building wheels for collected packages: opencv-python
Building wheel for opencv-python (PEP 517) ... error
ERROR: Command errored out with exit status 1:
command: 'c:\python\python.exe' 'c:\python\lib\site-packages\pip\_vendor\pep517\_in_process.py' build_wheel 'C:\Users\Austen\AppData\Local\Temp\tmp6zo4yrsx'
cwd: C:\Users\Austen\AppData\Local\Temp\pip-install-tcb_5anh\opencv-python
Complete output (153 lines):
Not searching for unused variables given on the command line.
CMake Error: CMake was unable to find a build program corresponding to "Ninja". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
-- Configuring incomplete, errors occurred!
See also "C:/Users/Austen/AppData/Local/Temp/pip-install-tcb_5anh/opencv-python/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
Not searching for unused variables given on the command line.
CMake Error at CMakeLists.txt:2 (PROJECT):
Generator
Visual Studio 15 2017 Win64
could not find any instance of Visual Studio.
-- Configuring incomplete, errors occurred!
See also "C:/Users/Austen/AppData/Local/Temp/pip-install-tcb_5anh/opencv-python/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
Not searching for unused variables given on the command line.
-- The C compiler identification is unknown
CMake Error at CMakeLists.txt:3 (ENABLE_LANGUAGE):
The CMAKE_C_COMPILER:
cl
is not a full path and was not found in the PATH.
To use the NMake generator with Visual C++, cmake must be run from a shell
that can use the compiler cl from the command line. This environment is
unable to invoke the cl compiler. To fix this problem, run cmake from the
Visual Studio Command Prompt (vcvarsall.bat).
Tell CMake where to find the compiler by setting either the environment
variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH.
********************************************************************************
----------------------------------------
ERROR: Failed building wheel for opencv-python
Failed to build opencv-python
ERROR: Could not build wheels for opencv-python which use PEP 517 and cannot be installed directly
I have successfully resolved this error issue. There are two methods of going about it, you can use either:
Downgrading Python 3.9 to Python 3.8
Use conda instead of pip (if you have python 3.9 installed and don't want to downgrade)
Cheers!

Issue when installing OpenCv using Pip

I need help to install OpenCv with Pip.
Everytime I type the pip install opencv-python command in the command prompt, I get this error :
C:\Users\me>pip install opencv-python
Collecting opencv-python
Using cached opencv-python-4.4.0.44.tar.gz (88.9 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Requirement already satisfied: numpy>=1.17.3 in e:\python\lib\site-packages (from opencv-python) (1.19.2)
Building wheels for collected packages: opencv-python
Building wheel for opencv-python (PEP 517) ... error
ERROR: Command errored out with exit status 1:
command: 'e:\python\python.exe' 'e:\python\lib\site-packages\pip\_vendor\pep517\_in_process.py' build_wheel 'C:\Users\me\AppData\Local\Temp\tmphs6y6kyz'
cwd: C:\Users\me\AppData\Local\Temp\pip-install-l8x74op7\opencv-python
Complete output (153 lines):
Not searching for unused variables given on the command line.
CMake Error: CMake was unable to find a build program corresponding to "Ninja". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
-- Configuring incomplete, errors occurred!
See also "C:/Users/me/AppData/Local/Temp/pip-install-l8x74op7/opencv-python/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
Not searching for unused variables given on the command line.
CMake Error at CMakeLists.txt:2 (PROJECT):
Generator
Visual Studio 15 2017 Win64
could not find any instance of Visual Studio.
-- Configuring incomplete, errors occurred!
See also "C:/Users/me/AppData/Local/Temp/pip-install-l8x74op7/opencv-python/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
Not searching for unused variables given on the command line.
-- The C compiler identification is unknown
CMake Error at CMakeLists.txt:3 (ENABLE_LANGUAGE):
The CMAKE_C_COMPILER:
cl
is not a full path and was not found in the PATH.
To use the NMake generator with Visual C++, cmake must be run from a shell
that can use the compiler cl from the command line. This environment is
unable to invoke the cl compiler. To fix this problem, run cmake from the
Visual Studio Command Prompt (vcvarsall.bat).
Tell CMake where to find the compiler by setting either the environment
variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH.
-- Configuring incomplete, errors occurred!
See also "C:/Users/me/AppData/Local/Temp/pip-install-l8x74op7/opencv-python/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/me/AppData/Local/Temp/pip-install-l8x74op7/opencv-python/_cmake_test_compile/build/CMakeFiles/CMakeError.log".
Not searching for unused variables given on the command line.
-- The C compiler identification is unknown
CMake Error at CMakeLists.txt:3 (ENABLE_LANGUAGE):
The CMAKE_C_COMPILER:
cl
is not a full path and was not found in the PATH.
To use the JOM generator with Visual C++, cmake must be run from a shell
that can use the compiler cl from the command line. This environment is
unable to invoke the cl compiler. To fix this problem, run cmake from the
Visual Studio Command Prompt (vcvarsall.bat).
Tell CMake where to find the compiler by setting either the environment
variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH.
-- Configuring incomplete, errors occurred!
See also "C:/Users/me/AppData/Local/Temp/pip-install-l8x74op7/opencv-python/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/me/AppData/Local/Temp/pip-install-l8x74op7/opencv-python/_cmake_test_compile/build/CMakeFiles/CMakeError.log".
--------------------------------------------------------------------------------
-- Trying "NMake Makefiles JOM (Visual Studio 15 2017 Win64 v141)" generator
--------------------------------
---------------------------
----------------------
-----------------
------------
-------
--
--
-------
------------
-----------------
----------------------
---------------------------
--------------------------------
-- Trying "NMake Makefiles JOM (Visual Studio 15 2017 Win64 v141)" generator - failure
--------------------------------------------------------------------------------
********************************************************************************
scikit-build could not get a working generator for your system. Aborting build.
Building windows wheels for Python 3.9 requires Microsoft Visual Studio 2017.
Get it with "Visual Studio 2017":
https://visualstudio.microsoft.com/vs/
********************************************************************************
----------------------------------------
ERROR: Failed building wheel for opencv-python
Failed to build opencv-python
ERROR: Could not build wheels for opencv-python which use PEP 517 and cannot be installed directly
If there are unoffical wheels available, then the easiest way to install it would be.
pip install pipwin
then
pipwin install opencv-python

Failed to build opencv-python

I'm using pycharm. I created a virtual environment to use and when I tried to install the opencv library, I got an error message.
I am using the pip command to install openCV:
Command:pip install opencv-python
This the the error message that appears when I use the command:
Error: -
Collecting opencv-python
Using cached https://files.pythonhosted.org/packages/e0/6f/237b730227927c15a68ec831a51bc83837bb65d54bf9651c08b474201b9a/opencv-python-4.4.0.40.tar.gz
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Requirement already satisfied: numpy>=1.17.3 in f:\python\rio python\project rio\reco_env\lib\site-packages (from opencv-python) (1.19.1)
Building wheels for collected packages: opencv-python
Building wheel for opencv-python (PEP 517) ... error
Complete output from command "F:\Python\Rio Python\Project Rio\Reco_env\Scripts\python.exe" "F:\Python\Rio Python\Project Rio\Reco_env\lib\site-packages\pip-19.0.3-py3.8.egg\pip\_vendor\pep517\_in_process.py" build_wheel C:\Users\Rio\AppData\Local\Temp\tmpew_pbwjp:
Not searching for unused variables given on the command line.
CMake Error: CMake was unable to find a build program corresponding to "Ninja". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
-- Configuring incomplete, errors occurred!
See also "C:/Users/Rio/AppData/Local/Temp/pip-install-gyo_26q6/opencv-python/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
Not searching for unused variables given on the command line.
CMake Error at CMakeLists.txt:2 (PROJECT):
Generator
Visual Studio 15 2017
could not find any instance of Visual Studio.
-- Configuring incomplete, errors occurred!
See also "C:/Users/Rio/AppData/Local/Temp/pip-install-gyo_26q6/opencv-python/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
Not searching for unused variables given on the command line.
-- The C compiler identification is unknown
CMake Error at CMakeLists.txt:3 (ENABLE_LANGUAGE):
The CMAKE_C_COMPILER:
cl
is not a full path and was not found in the PATH.
To use the NMake generator with Visual C++, cmake must be run from a shell
that can use the compiler cl from the command line. This environment is
unable to invoke the cl compiler. To fix this problem, run cmake from the
Visual Studio Command Prompt (vcvarsall.bat).
Tell CMake where to find the compiler by setting either the environment
variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH.
-- Configuring incomplete, errors occurred!
See also "C:/Users/Rio/AppData/Local/Temp/pip-install-gyo_26q6/opencv-python/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Rio/AppData/Local/Temp/pip-install-gyo_26q6/opencv-python/_cmake_test_compile/build/CMakeFiles/CMakeError.log".
Not searching for unused variables given on the command line.
-- The C compiler identification is unknown
CMake Error at CMakeLists.txt:3 (ENABLE_LANGUAGE):
The CMAKE_C_COMPILER:
cl
is not a full path and was not found in the PATH.
To use the JOM generator with Visual C++, cmake must be run from a shell
that can use the compiler cl from the command line. This environment is
unable to invoke the cl compiler. To fix this problem, run cmake from the
Visual Studio Command Prompt (vcvarsall.bat).
Tell CMake where to find the compiler by setting either the environment
variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH.
-- Configuring incomplete, errors occurred!
See also "C:/Users/Rio/AppData/Local/Temp/pip-install-gyo_26q6/opencv-python/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Rio/AppData/Local/Temp/pip-install-gyo_26q6/opencv-python/_cmake_test_compile/build/CMakeFiles/CMakeError.log".
--------------------------------------------------------------------------------
-- Trying "Ninja (Visual Studio 15 2017 v141)" generator
--------------------------------
---------------------------
----------------------
-----------------
------------
-------
--
--
-------
------------
-----------------
----------------------
---------------------------
--------------------------------
-- Trying "Ninja (Visual Studio 15 2017 v141)" generator - failure
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Trying "Visual Studio 15 2017 v141" generator
--------------------------------
---------------------------
----------------------
-----------------
------------
-------
--
--
-------
------------
-----------------
----------------------
---------------------------
--------------------------------
-- Trying "Visual Studio 15 2017 v141" generator - failure
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Trying "NMake Makefiles (Visual Studio 15 2017 v141)" generator
--------------------------------
---------------------------
----------------------
-----------------
------------
-------
--
--
-------
------------
-----------------
----------------------
---------------------------
--------------------------------
-- Trying "NMake Makefiles (Visual Studio 15 2017 v141)" generator - failure
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Trying "NMake Makefiles JOM (Visual Studio 15 2017 v141)" generator
--------------------------------
---------------------------
----------------------
-----------------
------------
-------
--
--
-------
------------
-----------------
----------------------
---------------------------
--------------------------------
-- Trying "NMake Makefiles JOM (Visual Studio 15 2017 v141)" generator - failure
--------------------------------------------------------------------------------
********************************************************************************
scikit-build could not get a working generator for your system. Aborting build.
Building windows wheels for Python 3.8 requires Microsoft Visual Studio 2017.
Get it with "Visual Studio 2017":
https://visualstudio.microsoft.com/vs/
********************************************************************************
----------------------------------------
Failed building wheel for opencv-python
Running setup.py clean for opencv-python
Failed to build opencv-python
Could not build wheels for opencv-python which use PEP 517 and cannot be installed directly
I also installed Visual Studio Community 2019, and tried with Visual Studio Community 2017, but I am still having the same issue.
Does anyone know how to solve this please?
solution: pip3 install --upgrade pip setuptools wheel
Install anaconda...I also had the same issue...But anaconda just paves it off
I believe your issue is happening because Cmake cannot find the cl compiler in your system's path. Try to locate it depending on your visual studio installed and then add it your system's path.
This is an example of the path where the cl.exe can be found. Now mine is 14.0, but yours might be different.
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin
I tried all the solutions and none of them solved my issue. Firstly, I was trying to download opencv-python-headless from my company's requirements file. Although, every time I executed the install operation it failed and gave this error.
conda install -c fastai opencv-python-headless=4.5.2.54
I separately installed opencv-python-headless like above and this really solved my issue, maybe it might be useful for too. So, maybe instead of pip, conda might be the solution.

Categories