IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 移动开发 -> M1安装 cvxpy cvxopt python3.8.2 -> 正文阅读

[移动开发]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

  移动开发 最新文章
Vue3装载axios和element-ui
android adb cmd
【xcode】Xcode常用快捷键与技巧
Android开发中的线程池使用
Java 和 Android 的 Base64
Android 测试文字编码格式
微信小程序支付
安卓权限记录
知乎之自动养号
【Android Jetpack】DataStore
上一篇文章      下一篇文章      查看所有文章
加:2022-03-21 21:02:21  更:2022-03-21 21:03:57 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/24 19:07:27-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码