LoginSignup
0
1

More than 1 year has passed since last update.

M1チップでHomebrewからnumpyまで入れる

Last updated at Posted at 2021-07-06

はじめに

先に結論を言うと、numpyはバージョン1.15.4を入れたかったんですが、それはできませんでした。
ご存知の方いらっしゃいましたら、教えてください。

下記が今回インストール出来たものです

  • homebrew
  • pyenv
  • Python3.9.4
  • numpy 1.21.0(latest)

行った手順

Homebrewを入れるところから記述させていただきます。

homebrew入れる

Homebrewのサイトを開く。

#サイトのコマンドを叩く(2021/07/06 時点)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
#上記を実行したら "Next Step" にあるechoコマンドを叩く。
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/ユーザ名/.zprofile
#上記の内容を反映
source /User/ユーザ名/.zprofile
#インストールができているか確認
#"Your system is ready to brew."と出ればOK
brew doctor

私はbrew doctorで config がなんたらと警告が出たので以下を参照して解決しました。
https://qiita.com/ponsuke0531/items/7ede97f6abe6129802c1

pyenv入れる

zsh環境なのでこちらのドキュメントのzsh環境用の記載を参考にしました。

brew install pyenv
brew install pyenv-virtualenv
echo 'eval "$(pyenv init --path)"' >> ~/.zprofile
source ~/.zprofile

Python3.9.4の環境を作る

3.8を入れようと思ったんですが、Rosettaを使用しても何故か入れられませんでした。
仕方ないので3.9.4を入れました。

pyenv install 3.9.4

~/workspaceという名前のディレクトリ下ではpython3.9.4を使うようにしたいと思います

pyenv virtualenv 3.9.4 python3.9
cd ~/workspace
pyenv local python3.9
# 以下で "Python 3.9.4 " と出ればOK
python -V

numpy1.15.4を入れる

以下のコマンドを叩いてnumpyのインストールを試みますが、大量のエラー文が表示されます。

pip install numpy==1.15.4
# 他に試したコマンド
pip3 install numpy==1.15.4

エラー

Building wheels for collected packages: numpy
  Building wheel for numpy (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /Users/username/.pyenv/versions/3.9.4/envs/python3.9/bin/python3.9 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/z5/03qjd30x79g3yj_mwr48hbp40000gn/T/pip-install-mgni2caq/numpy_3790ae5e326745d5ab445d94fd5bbb50/setup.py'"'"'; __file__='"'"'/private/var/folders/z5/03qjd30x79g3yj_mwr48hbp40000gn/T/pip-install-mgni2caq/numpy_3790ae5e326745d5ab445d94fd5bbb50/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/z5/03qjd30x79g3yj_mwr48hbp40000gn/T/pip-wheel-6y0i1096
       cwd: /private/var/folders/z5/03qjd30x79g3yj_mwr48hbp40000gn/T/pip-install-mgni2caq/numpy_3790ae5e326745d5ab445d94fd5bbb50/

(省略)

Installing collected packages: numpy
    Running setup.py install for numpy ... error
    ERROR: Command errored out with exit status 1:
     command: /Users/username/.pyenv/versions/3.9.4/envs/python3.9/bin/python3.9 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/z5/03qjd30x79g3yj_mwr48hbp40000gn/T/pip-install-mgni2caq/numpy_3790ae5e326745d5ab445d94fd5bbb50/setup.py'"'"'; __file__='"'"'/private/var/folders/z5/03qjd30x79g3yj_mwr48hbp40000gn/T/pip-install-mgni2caq/numpy_3790ae5e326745d5ab445d94fd5bbb50/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/z5/03qjd30x79g3yj_mwr48hbp40000gn/T/pip-record-xmeah240/install-record.txt --single-version-externally-managed --compile --install-headers /Users/username/.pyenv/versions/3.9.4/envs/python3.9/include/site/python3.9/numpy
         cwd: /private/var/folders/z5/03qjd30x79g3yj_mwr48hbp40000gn/T/pip-install-mgni2caq/numpy_3790ae5e326745d5ab445d94fd5bbb50/

    Note: if you need reliable uninstall behavior, then install
    with pip instead of using `setup.py install`:
      - `pip install .`       (from a git repo or downloaded source release)
      - `pip install numpy`   (last NumPy release on PyPi)

ERROR: Command errored out with exit status 1: /Users/username/.pyenv/versions/3.9.4/envs/python3.9/bin/python3.9 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/z5/03qjd30x79g3yj_mwr48hbp40000gn/T/pip-install-mgni2caq/numpy_3790ae5e326745d5ab445d94fd5bbb50/setup.py'"'"'; __file__='"'"'/private/var/folders/z5/03qjd30x79g3yj_mwr48hbp40000gn/T/pip-install-mgni2caq/numpy_3790ae5e326745d5ab445d94fd5bbb50/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/z5/03qjd30x79g3yj_mwr48hbp40000gn/T/pip-record-xmeah240/install-record.txt --single-version-externally-managed --compile --install-headers /Users/username/.pyenv/versions/3.9.4/envs/python3.9/include/site/python3.9/numpy Check the logs for full command output.

numpy1.21.0(latest)を入れる

上記のエラーにもあるんですが、以下コマンドによってlatestはインストールすることはできました。

pip install numpy

最後に

python3.8やnumpy1.15.4の件を鑑みると、現状だと基本的にはlatestなどの比較的新しいバージョンにしか対応していないのかもしれません。。。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1