python-安装包的默认路径与更改
python 安装包的默认路径与更改
python 安装包的默认路径与更改
每次总是用pip去安装包,但是有的时候电脑里有多个python安装包,不知道安装包安装在了哪里:
安装包命令如下: pip install numpy;
2.如何查看安装包的位置
python -m site ;
3.显示出来的结果如下:
C:\Users\siyaopeng>python -m site
sys.path = [
‘C:\Users\siyaopeng’,
‘E:\Python\python38.zip’,
‘E:\Python\DLLs’,
‘E:\Python\lib’,
‘E:\Python’,
‘E:\Python\lib\site-packages’,
]
USER_BASE: ‘C:\Users\siyaopeng\AppData\Roaming\Python’ (doesn’t exist)
USER_SITE: ‘C:\Users\siyaopeng\AppData\Roaming\Python\Python38\site-packages’ (doesn’t exist)
ENABLE_USER_SITE: True
user_site其实就是个人的site-packages默认安装路径了
4.下面就是到对应的文件夹去修改配置
5.cmd命令行窗口下键入:
python -m site -help
6.可以看到结果:
C:\Users\siyaopeng>python -m site -help
E:\Python\lib\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
7.可以看出是E:\Python\lib\site.py来管理这些配置
8.进入这个文件中,修改USER_BASE和USER_SITE
9.USER_BASE:执行下载的pip等脚本路径是由USER_BASE决定
USER_SITE:要安装下载的site-packages的路径
10.如何检查是否已修改成功:
命令行pip已安装的包,显示请求已满足
C:\Users\siyaopeng>pip install numpy
Requirement already satisfied: numpy in e:\python\lib\site-packages (1.19.4)