1. 查看Python安装和依赖信息:cmd命令窗口python -m site
E:\workspace\python\Django>python -m site sys.path = [ 'E:\\workspace\\python\\Django', 'D:\\Program Files\\python\\python37.zip', 'D:\\Program Files\\python\\DLLs', 'D:\\Program Files\\python\\lib', 'D:\\Program Files\\python', 'C:\\Users\\Administrator\\AppData\\Roaming\\Python\\Python37\\site-packages', 'D:\\Program Files\\python\\lib\\site-packages', 'D:\\Program Files\\python\\lib\\site-packages\\you_get-0.4.1475-py3.7.egg', ] USER_BASE: 'C:\\Users\\Administrator\\AppData\\Roaming\\Python' (exists) USER_SITE: 'C:\\Users\\Administrator\\AppData\\Roaming\\Python\\Python37\\site-packages' (exists) ENABLE_USER_SITE: True
可以看到
- python安装目录
- USER_SITE:自定义Python依赖安装包的基础路径
- USER_BASE:自定义Python脚本
- 查看依赖配置site.py的路径
python -m site -help # site.py的路径 D:\Program Files\python\lib\site.py [--user-base] [--user-site]
- 修改site.py
# USER_SITE = None # USER_BASE = None USER_SITE = "D:\\Program Files\\python\\Lib\\site-packages" USER_BASE = "D:\\Program Files\\python\\Scripts"
注意尽量写到python目录