M1安装 cvxpy cvxopt python3.8.2

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.

我的方法:

  1. 依赖库要全部先安装好
  2. 下载源码 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 <gsl/gsl_rng.h>
         ^~~~~~~~~~~~~~~
1 error generated.
error: command '/usr/bin/clang' failed with exit code 1

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
您可以按照以下步骤下载并安装Python 3.8.2: 1. 首先,访问Python官网https://www.python.org/,点击"downloads",找到您需要的版本(本教程使用的是3.8.2版本)并点击进入。 2. 在下载页面上,您会看到几个选项,选择符合您需求的版本。如果您的操作系统是32位的,选择x86版本;如果是64位的,选择x86-64版本。 3. 下载Python 3.8.2的安装包。您可以选择web-based installer进行联网安装,executable installer进行可执行文件安装,或者embeddable zip file进行嵌入式安装。 4. 下载完成后,双击打开安装包。根据您的需求选择默认安装或自定义安装,确保勾选下方的两个小框。 5. 等待安装完成。一旦安装成功,您将看到安装成功的提示。 6. 为了验证安装是否成功,您可以按下组合键“Win + R”,然后输入"cmd"并回车。在命令行中输入"python"并回车,如果出现Python的版本信息,说明安装成功。 希望这个教程对您有帮助!123 #### 引用[.reference_title] - *1* *2* [python 3.8.2安装教程](https://blog.csdn.net/weixin_44646187/article/details/124100969)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item] - *3* [Ubuntu 安装python3.8.2](https://blog.csdn.net/weixin_39872123/article/details/110015583)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值