前言
這次第一次我遇到的macOS安裝python模塊比win下安裝要麻煩的!網上找了很多方案,也都嘗試了,要么失敗要么過於繁瑣(=失敗),最后終於找到一個方法,無痛解決安裝問題!
安裝方法
使用open-mpi攜帶安裝:
- 打開mac的terminal終端:Press Command+Space and type Terminal and press enter/return key. Run in Terminal app:
- 輸入命令:ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null and press enter/return key.
注意應該是需要輸入開機密碼:If the screen prompts you to enter a password, please enter your Mac's user password to continue. When you type the password, it won't be displayed on screen, but the system would accept it. So just type your password and press ENTER/RETURN key. Then wait for the command to finish.
Run: - 先安裝open-mpi:brew install open-mpi
- 然后直接 pip install mpi4py 就完成了!