问题描述
我有 Python 3.7,Pip 版本 20.3.3,并尝试通过 Windows CMD 安装 CVXPY 包。它给了我如下所示的错误。即使手动安装 cmake,它也无法为 qdldl 构建轮子。
C:\Users\luncb\AppData\Local\Programs\Python\python37-32\Scripts>pip install cvxpy
Collecting cvxpy
Using cached cvxpy-1.1.7.tar.gz (1.0 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel Metadata ... done
Requirement already satisfied: scipy>=1.1.0 in c:\users\luncb\appdata\local\programs\python\python37-32\lib\site-packages (from cvxpy) (1.3.1)
Requirement already satisfied: numpy>=1.15 in c:\users\luncb\appdata\local\programs\python\python37-32\lib\site-packages (from cvxpy) (1.17.3)
Collecting ecos>=2
Using cached ecos-2.0.7.post1.tar.gz (126 kB)
Collecting osqp>=0.4.1
Using cached osqp-0.6.2.post0.tar.gz (219 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... error
ERROR: Command errored out with exit status 1:
command: 'c:\users\luncb\appdata\local\programs\python\python37-32\python.exe' 'c:\users\luncb\appdata\local\programs\python\python37-32\lib\site-packages\pip' install --ignore-installed --no-user --prefix 'C:\Users\luncb\AppData\Local\Temp\pip-build-env-b2iehl_l\normal' --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- qdldl
cwd: None
Complete output (130 lines):
Collecting qdldl
Using cached qdldl-0.1.5.post0.tar.gz (69 kB)
Collecting numpy>=1.7
Using cached numpy-1.19.5-cp37-cp37m-win32.whl (11.0 MB)
Collecting scipy>=0.13.2
Using cached scipy-1.6.0-cp37-cp37m-win32.whl (29.4 MB)
Building wheels for collected packages: qdldl
Building wheel for qdldl (setup.py): started
Building wheel for qdldl (setup.py): finished with status 'error'
ERROR: Command errored out with exit status 1:
command: 'c:\users\luncb\appdata\local\programs\python\python37-32\python.exe' -u -c 'import sys,setuptools,tokenize; sys.argv[0] = '"'"'C:\\Users\\luncb\\AppData\\Local\\Temp\\pip-install-8jqxxrdk\\qdldl_3bf837786c1f4cb5b09a61ead7c0f4f0\\setup.py'"'"'; __file__='"'"'C:\\Users\\luncb\\AppData\\Local\\Temp\\pip-install-8jqxxrdk\\qdldl_3bf837786c1f4cb5b09a61ead7c0f4f0\\setup.py'"'"';f=getattr(tokenize,'"'"'open'"'"',open)(__file__);code=f.read().replace('"'"'\r\n'"'"','"'"'\n'"'"');f.close();exec(compile(code,__file__,'"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\luncb\AppData\Local\Temp\pip-wheel-imz42pv5'
cwd: C:\Users\luncb\AppData\Local\Temp\pip-install-8jqxxrdk\qdldl_3bf837786c1f4cb5b09a61ead7c0f4f0\
Complete output (51 lines):
running bdist_wheel
running build
running build_ext
Traceback (most recent call last):
File "C:\Users\luncb\AppData\Local\Temp\pip-install-8jqxxrdk\qdldl_3bf837786c1f4cb5b09a61ead7c0f4f0\setup.py",line 78,in build_extensions
check_output(['cmake','--version'])
File "c:\users\luncb\appdata\local\programs\python\python37-32\lib\subprocess.py",line 395,in check_output
**kwargs).stdout
File "c:\users\luncb\appdata\local\programs\python\python37-32\lib\subprocess.py",line 472,in run
with Popen(*popenargs,**kwargs) as process:
File "c:\users\luncb\appdata\local\programs\python\python37-32\lib\subprocess.py",line 775,in __init__
restore_signals,start_new_session)
File "c:\users\luncb\appdata\local\programs\python\python37-32\lib\subprocess.py",line 1178,in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception,another exception occurred:
Traceback (most recent call last):
File "<string>",line 1,in <module>
File "C:\Users\luncb\AppData\Local\Temp\pip-install-8jqxxrdk\qdldl_3bf837786c1f4cb5b09a61ead7c0f4f0\setup.py",line 124,in <module>
ext_modules=[qdldl],File "c:\users\luncb\appdata\local\programs\python\python37-32\lib\site-packages\setuptools\__init__.py",line 145,in setup
return distutils.core.setup(**attrs)
File "c:\users\luncb\appdata\local\programs\python\python37-32\lib\distutils\core.py",line 148,in setup
dist.run_commands()
File "c:\users\luncb\appdata\local\programs\python\python37-32\lib\distutils\dist.py",line 966,in run_commands
self.run_command(cmd)
File "c:\users\luncb\appdata\local\programs\python\python37-32\lib\distutils\dist.py",line 985,in run_command
cmd_obj.run()
File "c:\users\luncb\appdata\local\programs\python\python37-32\lib\site-packages\wheel\bdist_wheel.py",line 223,in run
self.run_command('build')
File "c:\users\luncb\appdata\local\programs\python\python37-32\lib\distutils\cmd.py",line 313,in run_command
self.distribution.run_command(command)
File "c:\users\luncb\appdata\local\programs\python\python37-32\lib\distutils\dist.py",in run_command
cmd_obj.run()
File "c:\users\luncb\appdata\local\programs\python\python37-32\lib\distutils\command\build.py",line 135,in run
self.run_command(cmd_name)
File "c:\users\luncb\appdata\local\programs\python\python37-32\lib\distutils\cmd.py",in run_command
cmd_obj.run()
File "c:\users\luncb\appdata\local\programs\python\python37-32\lib\site-packages\setuptools\command\build_ext.py",line 84,in run
_build_ext.run(self)
File "c:\users\luncb\appdata\local\programs\python\python37-32\lib\site-packages\Cython\distutils\old_build_ext.py",line 186,in run
_build_ext.build_ext.run(self)
File "c:\users\luncb\appdata\local\programs\python\python37-32\lib\distutils\command\build_ext.py",line 340,in run
self.build_extensions()
File "C:\Users\luncb\AppData\Local\Temp\pip-install-8jqxxrdk\qdldl_3bf837786c1f4cb5b09a61ead7c0f4f0\setup.py",line 80,in build_extensions
raise RuntimeError("CMake must be installed to build qdldl")
RuntimeError: CMake must be installed to build qdldl
----------------------------------------
ERROR: Failed building wheel for qdldl
Running setup.py clean for qdldl
Failed to build qdldl
Installing collected packages: numpy,scipy,qdldl
Running setup.py install for qdldl: started
Running setup.py install for qdldl: finished with status 'error'
ERROR: Command errored out with exit status 1:
command: 'c:\users\luncb\appdata\local\programs\python\python37-32\python.exe' -u -c 'import sys,'"'"'exec'"'"'))' install --record 'C:\Users\luncb\AppData\Local\Temp\pip-record-wyco88bz\install-record.txt' --single-version-externally-managed --prefix 'C:\Users\luncb\AppData\Local\Temp\pip-build-env-b2iehl_l\normal' --compile --install-headers 'C:\Users\luncb\AppData\Local\Temp\pip-build-env-b2iehl_l\normal\Include\qdldl'
cwd: C:\Users\luncb\AppData\Local\Temp\pip-install-8jqxxrdk\qdldl_3bf837786c1f4cb5b09a61ead7c0f4f0\
Complete output (53 lines):
running install
running build
running build_ext
Traceback (most recent call last):
File "C:\Users\luncb\AppData\Local\Temp\pip-install-8jqxxrdk\qdldl_3bf837786c1f4cb5b09a61ead7c0f4f0\setup.py",in build_extensions
check_output(['cmake','--version'])
File "c:\users\luncb\appdata\local\programs\python\python37-32\lib\subprocess.py",in check_output
**kwargs).stdout
File "c:\users\luncb\appdata\local\programs\python\python37-32\lib\subprocess.py",in run
with Popen(*popenargs,**kwargs) as process:
File "c:\users\luncb\appdata\local\programs\python\python37-32\lib\subprocess.py",in __init__
restore_signals,start_new_session)
File "c:\users\luncb\appdata\local\programs\python\python37-32\lib\subprocess.py",in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception,another exception occurred:
Traceback (most recent call last):
File "<string>",in <module>
File "C:\Users\luncb\AppData\Local\Temp\pip-install-8jqxxrdk\qdldl_3bf837786c1f4cb5b09a61ead7c0f4f0\setup.py",in <module>
ext_modules=[qdldl],in setup
return distutils.core.setup(**attrs)
File "c:\users\luncb\appdata\local\programs\python\python37-32\lib\distutils\core.py",in setup
dist.run_commands()
File "c:\users\luncb\appdata\local\programs\python\python37-32\lib\distutils\dist.py",in run_commands
self.run_command(cmd)
File "c:\users\luncb\appdata\local\programs\python\python37-32\lib\distutils\dist.py",in run_command
cmd_obj.run()
File "c:\users\luncb\appdata\local\programs\python\python37-32\lib\site-packages\setuptools\command\install.py",line 61,in run
return orig.install.run(self)
File "c:\users\luncb\appdata\local\programs\python\python37-32\lib\distutils\command\install.py",line 545,in run
self.run_command('build')
File "c:\users\luncb\appdata\local\programs\python\python37-32\lib\distutils\cmd.py",in run_command
self.distribution.run_command(command)
File "c:\users\luncb\appdata\local\programs\python\python37-32\lib\distutils\dist.py",in run_command
cmd_obj.run()
File "c:\users\luncb\appdata\local\programs\python\python37-32\lib\distutils\command\build.py",in run
self.run_command(cmd_name)
File "c:\users\luncb\appdata\local\programs\python\python37-32\lib\distutils\cmd.py",in run_command
cmd_obj.run()
File "c:\users\luncb\appdata\local\programs\python\python37-32\lib\site-packages\setuptools\command\build_ext.py",in run
_build_ext.run(self)
File "c:\users\luncb\appdata\local\programs\python\python37-32\lib\site-packages\Cython\distutils\old_build_ext.py",in run
_build_ext.build_ext.run(self)
File "c:\users\luncb\appdata\local\programs\python\python37-32\lib\distutils\command\build_ext.py",in run
self.build_extensions()
File "C:\Users\luncb\AppData\Local\Temp\pip-install-8jqxxrdk\qdldl_3bf837786c1f4cb5b09a61ead7c0f4f0\setup.py",in build_extensions
raise RuntimeError("CMake must be installed to build qdldl")
RuntimeError: CMake must be installed to build qdldl
----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\luncb\appdata\local\programs\python\python37-32\python.exe' -u -c 'import sys,'"'"'exec'"'"'))' install --record 'C:\Users\luncb\AppData\Local\Temp\pip-record-wyco88bz\install-record.txt' --single-version-externally-managed --prefix 'C:\Users\luncb\AppData\Local\Temp\pip-build-env-b2iehl_l\normal' --compile --install-headers 'C:\Users\luncb\AppData\Local\Temp\pip-build-env-b2iehl_l\normal\Include\qdldl' Check the logs for full command output.
----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\luncb\appdata\local\programs\python\python37-32\python.exe' 'c:\users\luncb\appdata\local\programs\python\python37-32\lib\site-packages\pip' install --ignore-installed --no-user --prefix 'C:\Users\luncb\AppData\Local\Temp\pip-build-env-b2iehl_l\normal' --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- qdldl Check the logs for full command output.
解决方法
我遇到了同样的问题,您可能应该安装 cmake。首先,测试您是否拥有它:
$ cmake --version
如果没有,请通过以下方式安装:
$ sudo apt install cmake
最后,您应该能够安装 cvxpy:
$ pip install cvxpy