PYTHONUSERBASE
When installing with pip, if you add the --user
option, it will be installed in the user directory, which is convenient when there is a permission, but I wanted to change the installation destination from the default.
According to pip [^ 1], it follows python's site.USER_BASE
, so if you look at the explanation [^ 2] of site.USER_BASE
and the explanation [^ 3] of PYTHONUSERBASE
,
~ / .local
, ~ / Library
, and % APPDATA%
.PYTHONUSERBASE
It seems.
So, setting PYTHONUSERBASE
or site.USER_BASE
will solve the problem.
export PYTHONUSERBASE=/home/username/local
pip
#!/home/username/local/bin/python
# -*- coding: utf-8 -*-
import re
import sys
import site
from pip import main
if __name__ == '__main__':
site.USER_BASE = "/home/username/local"
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())
Recommended Posts