[PYTHON] What to do if the user name is changed and the pyenv library path does not pass

Overview

If the user name is changed and the home directory is renamed, pyenv may get stuck. This is because the python path referenced by the library in pyenv's environment is usually in your home directory, but it doesn't work. It can be solved by the following method. The correspondence is the same for pyenv-virtualenv. Environment: Ubuntu 16.04

procedure

#Get environment name
$ pyenv versions
 
$ vi ~/.pyenv/versions/Environment name/bin/pip

I think the first line looks like this:

#!/home/Old user name/.pyenv/versions/Environment name/bin/python3.*

This is the so-called shebang that specifies the interpreter to read in the interpreter language. The ID is still old, so change it to a new one.

#!/home/New user name/.pyenv/versions/Environment name/bin/python3.*

Now pip works. After that, you can change it uniformly by reinstalling other libraries.

$ pip freeze > requirements.txt
$ pip install -r requirements.txt

Recommended Posts

What to do if the user name is changed and the pyenv library path does not pass
What to do if pyenv is not enabled (zsh)
What to do if Python does not switch from the System version in pyenv
What to do if pyenv install does not proceed with an error
How to pass the path to the library built with pyenv and virtualenv in PyCharm
[Note] What to do if the Qt library conflicts between pyqt and opencv
[EC2] What to do when selenium is stuck and processing does not proceed
What to do if the progress bar is not displayed in tqdm of python
What to do if you get the error "Error: opencv3: Does not support building both Python 2 and 3 wrappers" when installing openCV 3
What to do if the image is not displayed using matplotlib etc. in the Docker container
What to do if the inode is exhausted on EC2 Linux
What to do if you cat or tail a binary file and the terminal is garbled
What to do if the Pipenv environment is corrupted by updating Homebrew
Example of what to do when the sample script does not work (OpenCV-Python)
What to do if the latest Jupyter Notebook and nb extensions don't work
What to do when the graph does not appear in jupyter (ipython) notebook
What to do if Japanese language support is not completely installed on Ubuntu 16.04
What to do if (base) is displayed at the beginning of the Mac terminal
What to do when is not in the sudoers file.This incident will be reported.
What to do if Python IntelliSense is not displayed in VS Code on Windows
How to install and use pyenv, what to do if you can't switch python versions
[Introduction to Python] What is the important "if __name__ =='__main__':" when dealing with modules?
Do not pass self to ProcessPoolExecutor in the class
Addresses an issue where an error does not occur even if the path does not pass when trying to read an image with cv2.imread ()
What to do if Jupyter Notebook on WSL does not start automatically in your browser
What to do when Japanese is not displayed on matplotlib
Why django-import-export import is so slow and what to do
[VSCode] unable to import'google.cloud' What to do when pylint (import-error) does not recognize the Python import statement
What to do if pip --user returns an error in a virtual environment created with pyenv
NameError: global name'dot_parser' is not defined and what to do when it comes up in python
How to give and what the constraints option in scipy.optimize.minimize is
What to do when the jupyterlab extension settings are not reflected
What to do if "Unnamed: 0" is added in to_csv-> read_csv in pandas
What to do if you can't use the trash in Lubuntu 18.04.
What to do when the value type is ambiguous in Python?
What to do if you get the message "" ~ .pkg "is corrupted and cannot be opened" when installing wxPython on Mac OS X
What to do if you get "The session could not be opened" when installing CentOS on VirtualBox
Determine if the library is installed.
What to do in my case when pyenv install is not possible after upgrading to macOS Big Sur
What to do if there is a decimal in python json .dumps
What to do when the result downloaded via scrapy is in English
[Introduction to Python] What is the difference between a list and a tuple?
What to do if ipython and python start up with different versions
What does it mean to go through the PATH? Where are the commands?
What to do if the yum command fails to set locale, defaulting to C
What to do if the Chainer (Windows) sample mnist terminates with WinError 183.
What to do if the server doesn't start with python manage.py runserver
What to do if you get Could not fetch URL 443 with pip
Notes on what to do when matplotlib scatter () / scatter3d () does not work
What to do if you installed pyenv on Mac OS using Homebrew but the python version doesn't switch
Even if the development language is changed to python3 in Cloud9, version 2 is displayed in python --version
What to do if you get angry with swapon failed: Operation not permitted
What to do if CERTIFICATE_VERIFY_FAILED occurs when nltk.download () is done on macOS pyhon
A story that sometimes does not work if pip is up to date
Let's Encrypt updated! What to do if the certbot renew command doesn't work
What to do if you get an error when installing python with pyenv
What to do if you get "Python not configured." Using PyDev in Eclipse
What to do if abort is displayed when inputting camera video in OpenCV
Is Parallel Programming Hard, And, If So, What Can You Do About It?
What to do if NotADirectoryError: [Errno 20] Not a directory:'xdg-settings' appears in jupyter notebook
Examples and solutions that the Python version specified in pyenv does not run