LoginSignup
0
0

More than 1 year has passed since last update.

PythonのインストールをHomebrewからpyenvにする

Posted at

概要

気付いたら動かなくなっていたので、ついでにPythonのインストール方法を変更した際のメモです。

最終更新日
2021年12月11日

環境
macOS Catalina 10.15.7
anyenv インストール済み

Homebrewからアンインストール

% brew uninstall python
Error: Refusing to uninstall /usr/local/Cellar/python@3.9/3.9.9
because it is required by cairo, fontforge, glib, gobject-introspection, harfbuzz and pango, which are currently installed.

依存モジュールもアンインストールします。
アンインストールしようとすると、他のモジュールに利用されていて同じエラーが出るので、エラーのでない物を探して末端のものから順番にしていきます。

% brew uninstall fontforge
% brew uninstall pango
% brew uninstall harfbuzz
% brew uninstall gobject-introspection
% brew uninstall cairo
% brew uninstall glib
% brew uninstall python

anyenvからpyenvをインストール

% anyenv install pyenv
...省略
Install pyenv succeeded!
Please reload your profile (exec $SHELL -l) or open a new session.

ターミナルを再起動します。
pyenvが動くか確認します。

% pyenv install -l
Available versions:
  2.1.3
  2.2.3
... 省略

pyenvからPythonをインストール

初期化しておきます。

% eval "$(pyenv init -)" 

この時は3.10.1が最新だったので、3.10.1を入れます。

% pyenv install 3.10.1
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.10.1.tar.xz...
... 省略

インストールできたか確認します。

% pyenv versions
* system (set by /Users/****/.anyenv/envs/pyenv/version)
  3.10.1

利用バージョンを指定します。

% pyenv global 3.10.1 

できたか確認します。

% python --version
Python 3.10.1

無事にできました。

おまけ

percolを入れ直し。

% sudo pip install percol
0
0
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
0