Skip to content

Commit 8ada1d0

Browse files
authored
Merge pull request sngyai#48 from ethqunzhong/qunzhong-update-M1-macos-install-readme
update description: add M1 MacOS arm64 ta-lib install guide
2 parents 9eacc2b + 69b4e05 commit 8ada1d0

2 files changed

Lines changed: 68 additions & 4 deletions

File tree

README.md

Lines changed: 67 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,76 @@
99
## 准备工作:
1010
### 根据不同的平台安装TA-Lib程序
1111

12-
* Mac OS X
12+
13+
推荐使用 Miniconda来进行 Python 环境管理 [Miniconda — conda documentation](https://docs.conda.io/en/latest/miniconda.html)
14+
切换到项目专属环境进行配置
15+
```
16+
conda create -n sequoia39 python=3.9
17+
conda activate sequoia39
18+
```
19+
20+
* Mac OS X (x86_64)
21+
22+
```
23+
$ brew install ta-lib
24+
# conda 环境下 可直接执行
25+
$ conda install -c conda-forge ta-lib
26+
```
27+
28+
* Mac OS X (arm64)
29+
30+
需要特殊说明的是
31+
M1 芯片的 Mac OS 很多依赖都需要基于 arm64 来构建。
32+
这里,首先需要确认安装的 brew 是 arm 版本,如果之前安装的 brew 是 x86 版本,推荐重装 brew。
33+
1. 删除老版本 brew
34+
```
35+
sudo rm -rf /usr/local/.git
36+
rm -rf ~/Library/Caches/Homebrew
37+
rm -rf /usr/local/Homebrew
38+
```
39+
40+
2. 安装/重装 arm 版本 homebrew
41+
```
42+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
43+
```
44+
45+
3. homebrew 初始化
46+
```
47+
vim ~/.zshrc
48+
49+
# 加入到系统环境变量
50+
export PATH=/opt/homebrew/bin:$PATH
51+
52+
source ~/.zshrc
53+
# 确认版本信息
54+
brew config
55+
```
56+
4. 过程中遇到问题的参考解决办法
57+
- [macos - zsh problem: compinit:503: no such file or directory: /usr/local/share/zsh/site-functions/_brew - Stack Overflow](https://stackoverflow.com/questions/65747286/zsh-problem-compinit503-no-such-file-or-directory-usr-local-share-zsh-site)
58+
- [The required file "libmini_racer.dylib" can't be found in mac M1 · Issue #143 · sqreen/PyMiniRacer](https://github.com/sqreen/PyMiniRacer/issues/143)
59+
- [Installing python tables on mac with m1 chip - Stack Overflow](https://stackoverflow.com/questions/65839750/installing-python-tables-on-mac-with-m1-chip)
60+
61+
5. 经过以上步骤后,可以开始继续安装 `ta-lib` 了。 参考
62+
- [TA-Lib · PyPI](https://pypi.org/project/TA-Lib/)
63+
- [说说 talib(ta-lib) 这个技术指标库,各系统怎么最轻松安装 ta-lib - 知乎](https://zhuanlan.zhihu.com/p/546720500)
1364
1465
```
15-
$ brew install ta-lib
66+
# 操作示例
67+
# 1. 创建专属 python 环境
68+
conda create -n sequoia39 python=3.9
69+
conda activate sequoia39
70+
71+
# 2. 安装 ta-lib 库
72+
arch -arm64 brew install ta-lib
73+
export TA_INCLUDE_PATH="$(brew --prefix ta-lib)/include"
74+
export TA_LIBRARY_PATH="$(brew --prefix ta-lib)/lib"
75+
python3.9 -m pip install --no-cache-dir ta-lib
76+
77+
# 验证是否安装成功
78+
python -c "import talib; print(talib.__version__)"
1679
```
1780
81+
1882
* Windows
1983
2084
下载 [ta-lib-0.4.0-msvc.zip](http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-msvc.zip),解压到 ``C:\ta-lib``
@@ -76,5 +140,4 @@ $ python main.py
76140
修改[config.yaml](config.yaml.example)`end_date`为指定日期,格式为`'YYYY-MM-DD'`,如:
77141
```
78142
end = '2019-06-17'
79-
```
80-
143+
```

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ numpy==1.23.5
55
xlrd==1.2.0
66
TA-Lib==0.4.25
77
tables==3.7.0
8+
# install schedule 可能遇到的问题及 fix 见:https://github.com/sngyai/Sequoia/issues/26
89
schedule==0.6.0
910
wxpusher==2.2.0
1011
pytest==7.2.0

0 commit comments

Comments
 (0)