HomeBrewでpython3をインストール
インストール可能なpython一覧を表示する
searchコマンドを使用してインストール可能な一覧を表示します.この中から必要なものをインストールします.
$ brew search python app-engine-python python-launcher python@3.8 boost-python python-markdown python@3.9 boost-python3 python-tabulate reorder-python-imports bpython python-tk@3.10 wxpython gst-python python-tk@3.9 pythran ipython python-yq jython micropython python@3.10 cython ptpython python@3.7
python@3.10をインストールする
searchコマンドの一覧の中から選択してインストールします.
$ brew install python@3.10 ~~省略~ Python has been installed as /opt/homebrew/opt/python@3.10/bin/python3 Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to `python3`, `python3-config`, `pip3` etc., respectively, have been installed into /opt/homebrew/opt/python@3.10/libexec/bin You can install Python packages with /opt/homebrew/opt/python@3.10/bin/pip3 install <package> They will install into the site-package directory /opt/homebrew/lib/python3.10/site-packages tkinter is no longer included with this formula, but it is available separately: brew install python-tk@3.10 See: https://docs.brew.sh/Homebrew-and-Python python@3.10 is keg-only, which means it was not symlinked into /opt/homebrew, because this is an alternate version of another formula. If you need to have python@3.10 first in your PATH, run: echo 'export PATH="/opt/homebrew/opt/python@3.10/bin:$PATH"' >> ~/.zshrc For compilers to find python@3.10 you may need to set: export LDFLAGS="-L/opt/homebrew/opt/python@3.10/lib"
インストールすると説明が出てきます,このままではpathが通っていないので設定するように言われています.
$ echo 'export PATH="/opt/homebrew/opt/python@3.10/bin:$PATH"' >> ~/.zshrc
起動時にpathを通すように設定しておきます.
確認する
最後に確認して終了です.
$ which python3 /opt/homebrew/opt/python@3.10/bin/python3 $ python3 --version Python 3.10.2 $ which pip3 /opt/homebrew/opt/python@3.10/bin/pip3
無事使えるようになりました.