LoginSignup
20
19

More than 3 years have passed since last update.

Homebrew の Python をアップグレードした後に virtualenv の python も再リンクする

Last updated at Posted at 2015-06-16

brew cleanup とかでリンクがキレて

app: source venv/bin/activate
[venv] app: python
dyld: Library not loaded: @executable_path/../.Python
  Referenced from: /path/to/app/venv/bin/python
  Reason: image not found

Python 3.x 系

アプリケーションディレクトリー内に venv ディレクトリーを利用している場合

find ./.venv -type l -delete && python3 -m venv ./.venv

.venv は適宜仮想環境ディレクトリーを指定してください

Python 2.x 系

virtualenv を利用している場合

みたいになったやつの再リンク。方法は env ディレクトリのリンクを消して、 virtualenv コマンドで再リンクするだけ

find ./venv -type l -delete && virtualenv ./venv

1個1個再リンクするのめんどい。 virtualenvwrapper 使ってることと以下のように一括で更新できる

workon | xargs -L 1 -t -P 4 -I % -- sh -c 'find $WORKON_HOME/% -type l -delete && virtualenv $WORKON_HOME/%'
  • -P 4 を作成している virtualenv の個数分ぐらいに増やして並列処理すると早い.
20
19
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
20
19