Python pip install如何修改默认下载路径

Lewa ·
更新时间:2024-09-20
· 754 次阅读

pip动不动就下载数百M的文件。这些文件默认在C:盘,那么为了节省空间需要修改这些路径:

打开cmd命令窗口。输入:

python -m site

C:\Users\hewei>python -m site sys.path = [ 'C:\\Users\\xxx', 'D:\\Program Files\\Python37\\python37.zip', 'D:\\Program Files\\Python37\\DLLs', 'D:\\Program Files\\Python37\\lib', 'D:\\Program Files\\Python37', 'D:\\Program Files\\Python37\\lib\\site-packages', ] USER_BASE: 'C:\\Users\\xxx\\AppData\\Roaming\\Python' (doesn't exist) USER_SITE: 'C:\\Users\\xxx\\AppData\\Roaming\\Python\\Python37\\site-packages' (doesn't exist) ENABLE_USER_SITE: True

可以看到你的python安装目录,和

USER_SITE:自定义Python依赖安装包的基础路径。

USER_BASE:自定义Python脚本

python -m site -help

查看site.py的路径

C:\Users\hewei>python -m site -help
D:\Program Files\Python37\lib\site.py [--user-base] [--user-site]

打开site.py 修改:

修改为自己路径。这里要注意尽量写到python目录下

在利用pip谁便安装一个包。去USER_SITE目录下发现包在这里已经成功了

您可能感兴趣的文章:python用pip install时安装失败的一系列问题及解决方法Python解决pip install时出现的Could not fetch URL问题更改Python的pip install 默认安装依赖路径方法详解python2.7无法使用pip的解决方法(安装easy_install)python3安装pip3(install pip3 for python 3.x)Python中easy_install 和 pip 的安装及使用centos6.7 安装python2.7、pip2.7、easy_install-2.7的方法Windows安装Python、pip、easy_install的方法



pip install 默认 install pip Python

需要 登录 后方可回复, 如果你还没有账号请 注册新账号