Python——pip的几个常见用法

pip卸载库命令

python unstall filename

pip更新命令

python -m pip install --upgrade pip

pip修改文件默认安装路径

python -m site

首先,通过上面的命令我们会发现,pip默认安装路径是如下 在这里插入图片描述
但是因为个人并不喜欢在系统盘中有太多的文件,所以想要修改默认下载位置,因此,我在这又用了一条命令。

python -m site -help

在这里插入图片描述
在这里我知道了,他的配置文件是site.py,那我只需要修改他的配置就可以了。

# Prefixes for site-packages; add additional prefixes like /usr/local here
PREFIXES = [sys.prefix, sys.exec_prefix]
# Enable per user site-packages directory
# set it to False to disable the feature or True to force the feature
ENABLE_USER_SITE = None

# for distutils.commands.install
# These values are initialized by the getuserbase() and getusersitepackages()
# functions, through the main() function when Python starts.
USER_SITE = None
USER_BASE = None

将我们需要的地方修改成

USER_SITE = "D:\python\Python37\Lib\site-packages"
USER_BASE = "D:\python"

保存后我们再调用下上面的一个命令

python -m site

这时候我们就会发现默认的路径已经修改了。
然后我在之后下载库的时候就用以下命令

python -m pip install -U flask --user

它会有个警告出来,但是可以忽略不计,文件已经进入新的路径并且下载成功了!

发布了5 篇原创文章 · 获赞 3 · 访问量 95

猜你喜欢

转载自blog.csdn.net/weixin_42887211/article/details/105368946
今日推荐