M1安装 cvxpy cvxopt python3.8.2

M1安装 cvxpy cvxopt python3.8.2,第1张

python3.8.2

安装cvxpy

官网installation安装先试一遍 不行再考虑下面的
要先 brew install cmake
https://www.cvxpy.org/install/index.html

Apple M1 users have had trouble installing CVXPY using the commands above. 
That trouble stemmed partly from a configuration error in CVXPY’s pyproject.toml, which has been fixed in CVXPY 1.1.19 and 1.2.0. 
If you have those versions (or newer) then the above commands should work provided (1) you have cmake installed via Homebrew and (2) you have an ECOS 2.0.5 wheel. 
The cmake requirement stems from OSQP and there appear to be problems building more recent versions of ECOS on M1 machines. See this comment on the CVXPY repo and this issue on the ECOS repo for more information.

指定安装ecos的版本
ecos==2.0.5
pip安装cvxpy还是出错



  clang: error: the clang compiler does not support 'faltivec', please use -maltivec and include altivec.h explicitly
            clang: error: the clang compiler does not support 'faltivec', please use -maltivec and include altivec.h explicitly
            clang: error: the clang compiler does not support 'faltivec', please use -maltivec and include altivec.h explicitly
            clang: error: the clang compiler does not support 'faltivec', please use -maltivec and include altivec.h explicitly
            clang: error: the clang compiler does not support 'faltivec', please use -maltivec and include altivec.h explicitly
            error: Command "clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/Headers -arch arm64 -arch x86_64 -Werror=implicit-function-declaration -DNPY_INTERNAL_BUILD=1 -DHAVE_NPY_CONFIG_H=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -DNO_ATLAS_INFO=3 -DHAVE_CBLAS -Ibuild/src.macosx-10.14.6-arm64-3.8/numpy/core/src/umath -Ibuild/src.macosx-10.14.6-arm64-3.8/numpy/core/src/npymath -Ibuild/src.macosx-10.14.6-arm64-3.8/numpy/core/src/common -Inumpy/core/include -Ibuild/src.macosx-10.14.6-arm64-3.8/numpy/core/include/numpy -Inumpy/core/src/common -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -I/Users/jiali/Desktop/multitask/FedEM-main/venv/include -I/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8 -Ibuild/src.macosx-10.14.6-arm64-3.8/numpy/core/src/common -Ibuild/src.macosx-10.14.6-arm64-3.8/numpy/core/src/npymath -Ibuild/src.macosx-10.14.6-arm64-3.8/numpy/core/src/common -Ibuild/src.macosx-10.14.6-arm64-3.8/numpy/core/src/npymath -c numpy/core/src/multiarray/alloc.c -o build/temp.macosx-10.14.6-arm64-3.8/numpy/core/src/multiarray/alloc.o -MMD -MF build/temp.macosx-10.14.6-arm64-3.8/numpy/core/src/multiarray/alloc.o.d -faltivec -I/System/Library/Frameworks/vecLib.framework/Headers" failed with exit status 1
            [end of output]
      
        note: This error originates from a subprocess, and is likely not a problem with pip.
      error: legacy-install-failure
      
      × Encountered error while trying to install package.
      ╰─> numpy
      
      note: This is an issue with the package mentioned above, not pip.
      hint: See above for output from the failure.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.

我的方法:

依赖库要全部先安装好下载源码 source code 安装
If you want to use CVXPY with editable source code, run

pip install -e .
otherwise, run

pip install .

输入命令:arch -x86_64 pip install -e .

arch -x86_64 pip install -e .
Obtaining file:///Users/jiali/Downloads/cvxpy-1.2.0
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: scipy>=1.1.0 in /Users/jiali/Desktop/multitask/FedEM-main/venv/lib/python3.8/site-packages (from cvxpy==1.2.0) (1.8.0)
Requirement already satisfied: ecos>=2 in /Users/jiali/Desktop/multitask/FedEM-main/venv/lib/python3.8/site-packages (from cvxpy==1.2.0) (2.0.5)
Requirement already satisfied: scs>=1.1.6 in /Users/jiali/Desktop/multitask/FedEM-main/venv/lib/python3.8/site-packages (from cvxpy==1.2.0) (3.2.0)
Requirement already satisfied: numpy>=1.15 in /Users/jiali/Desktop/multitask/FedEM-main/venv/lib/python3.8/site-packages (from cvxpy==1.2.0) (1.22.3)
Requirement already satisfied: osqp>=0.4.1 in /Users/jiali/Desktop/multitask/FedEM-main/venv/lib/python3.8/site-packages (from cvxpy==1.2.0) (0.6.2.post5)
Requirement already satisfied: qdldl in /Users/jiali/Desktop/multitask/FedEM-main/venv/lib/python3.8/site-packages (from osqp>=0.4.1->cvxpy==1.2.0) (0.1.5.post0)
Installing collected packages: cvxpy
  Running setup.py develop for cvxpy
Successfully installed cvxpy-1.2.0

我如果强行arch -x86_64 pip install cvxpy
虽然可以安装成功 但是_cvxcore.cpython-38m-darwin.so会出问题
大概错误长的样子:import _cvxcore ImportError: dlopen(---- (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/lib/libxcrun.dylib' (no such file)).
大概意思就是需要的是arm64的 给的文件名不对…所以不行

安装cvxopt

http://cvxopt.org/install/index.html

pip install cvxopt报错

     clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/Headers -arch arm64 -arch x86_64 -Werror=implicit-function-declaration -I/usr/local/include -I/Users/jiali/Desktop/multitask/FedEM-main/venv/include -I/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8 -c src/C/umfpack.c -o build/temp.macosx-10.14.6-arm64-3.8/src/C/umfpack.o
      src/C/umfpack.c:23:10: fatal error: 'umfpack.h' file not found
      #include "umfpack.h"
               ^~~~~~~~~~~
      1 error generated.
      error: command '/usr/bin/clang' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> cvxopt

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

尝试的方法1

https://blog.csdn.net/weixin_34219944/article/details/91918784

第一步:brew tap homebrew/science出错

==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
  https://github.com/Homebrew/brew#donations
Error: homebrew/science was deprecated. This tap is now empty and all its contents were either deleted or migrated.

不行

尝试的方法2

官网
下源码安装

xcode-select -p
brew install gsl fftw suite-sparse glpk
git clone https://github.com/cvxopt/cvxopt.git
cd cvxopt
git checkout `git describe --abbrev=0 --tags`
export CVXOPT_BUILD_FFTW=1    # optional
export CVXOPT_BUILD_GLPK=1    # optional
export CVXOPT_BUILD_GSL=1     # optional
python setup.py install

要是直接下载下来的话直接进文件夹就行了…
出错:

creating build/temp.macosx-10.14.6-arm64-3.8
creating build/temp.macosx-10.14.6-arm64-3.8/src
creating build/temp.macosx-10.14.6-arm64-3.8/src/C
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/Headers -arch arm64 -arch x86_64 -Werror=implicit-function-declaration -I/usr/include/gsl -I/Users/jiali/Desktop/multitask/FedEM-main/venv/include -I/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8 -c src/C/gsl.c -o build/temp.macosx-10.14.6-arm64-3.8/src/C/gsl.o
src/C/gsl.c:28:10: fatal error: 'gsl/gsl_rng.h' file not found
#include 
         ^~~~~~~~~~~~~~~
1 error generated.
error: command '/usr/bin/clang' failed with exit code 1

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/990492.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存