pip安装路径由.local调整为/usr/local

如果没有设置PYTHONUSERBASE,默认会安装在~/.local下

如果不希望安装在.local目录下,可以通过配置环境变量PYTHONUSERBASE指定对应的路径,比如/usr/local

当然也可以直接修改site.py的_getuserbase方法,通过设置USER_SITE和USER_BASE来指定

即调整USER SITE有2种方式:

1. 设置环境变量PYTHONUSERBASE

2. 设置site.py的对象变量USER_SITE和USER_BASE

 

 

$ export PYTHONUSERBASE=/usr/local
$ source .bashrc

$ python3 -m site -help
/usr/lib/python3.8/site.py [--user-base] [--user-site]

Without arguments print some useful information
With arguments print the value of USER_BASE and/or USER_SITE separated
by ':'.

Exit codes with --user-base or --user-site:
  0 - user site directory is enabled
  1 - user site directory is disabled by user
  2 - uses site directory is disabled by super user
      or for security reasons
 >2 - unknown error


$ python3 -m site 
sys.path = [
    '/home/V01/uidq2578',
    '/usr/lib/python38.zip',
    '/usr/lib/python3.8',
    '/usr/lib/python3.8/lib-dynload',
    '/usr/local/lib/python3.8/dist-packages',
    '/usr/lib/python3/dist-packages',
]
USER_BASE: '/usr/local' (exists)
USER_SITE: '/usr/local/lib/python3.8/site-packages' (doesn't exist)
ENABLE_USER_SITE: True

 

posted @ 2023-12-20 19:01  sciapex  阅读(167)  评论(0编辑  收藏  举报