LoginSignup
2
3

More than 3 years have passed since last update.

user名が変更になってpyenvのライブラリのパスが通らなくなった場合の対応

Last updated at Posted at 2020-09-14

概要

user名が変更になり、ホームディレクトリの名前が変更されると、pyenvが動かなくなることがあります。これは、pyenvの環境にあるライブラリが参照しているpythonのパスが通常ホームディレクトリ内にあるのですが、通らなくなることによります。以下の方法で解消可能です。pyenv-virtualenvでも対応は同様です。
環境: Ubuntu 16.04

手順

# 環境名取得
$ pyenv versions

$ vi ~/.pyenv/versions/環境名/bin/pip

一行目は以下のようになっていると思います。

#!/home/旧user名/.pyenv/versions/環境名/bin/python3.*

これはインタプリタ言語において、読み込むインタプリタを指定するいわゆるシバンというものです。IDが古いままですので、新しいものに変更します。

#!/home/新user名/.pyenv/versions/環境名/bin/python3.*

これでpipが動くようになりました。あとは、他のライブラリも再インストールすれば一律変更できます。

$ pip freeze > requirements.txt
$ pip install -r requirements.txt
2
3
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
2
3