原创

M1 Mac 安装numpy和pandas

M1 mac安装python3.9 arm64版之后,通过pip3安装numpy、pandas及matplotlib等包时,会出现错误。原因有很多文章可以参考不再赘述。下面介绍一种可以成功安装这些包的方法。

首先安装miniforge,他可以理解成是默认使用conda forge这个channel的miniconda,由github上一个团队负责维护,优点是包版本较新,最大的优点是支持arm mac!

https://github.com/conda-forge/miniforge/#download

点击下载arm64版本的miniforge:

注意,arm64版本的miniforge的基础环境是python3.9

在终端中打开下载文件所在目录,bash安装

bash Miniforge3-MacOSX-arm64.sh

按照指示完成安装。(注意安装完成后会问你是否将conda的base环境设为终端打开的默认环境,不需要的话回复no,但是目前推荐yes,因为conda下的python环境比目前系统自带的更完善,且安装各种包的限制少)

接下来通过conda新建虚拟环境,安装numpy、pandas和matplotlib:

可以先创建虚拟环境再一一install

conda create -n py39t python=3.9

conda install -n py39t numpy

conda install -n py39t matplotlib

conda install -n py39t pandas

conda activate py39t #换到刚创建的py39t环境下

pip list #查看已安装的包,完成

当然,也可以在创建虚拟环境的时候就安装所需的包

conda create -n py39t numpy matplotlib pandas python=3.9

大功告成!

Reference

M1 Mac 安装numpy和pandas_HLJs_Cookbook的博客-CSDN博客

https://blog.csdn.net/HLJs_Cookbook/article/details/111399621

M1 Mac 安装tushare

pycharm项目下打开终端,pip install tushare.

不知道是否和miniforge冲突,目前项目能跑

正文到此结束