Python之查看pip安装包site-package的位置

本文介绍查找pip site-package位置的两种方法

方法一:通过Python内置方法get_python_lib查询

from distutils.sysconfig import get_python_lib
print(get_python_lib())
# /Library/Python/3.7/site-packages

方法二:通过pip3命令直接查看

查看已安装的库的列表:pip3 list

xxxx@MacBook-Pro ~ % pip3 list
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
Package            Version
------------------ ---------
aniso8601          8.0.0
appdirs            1.4.4
appnope            0.1.0
argon2-cffi        20.1.0
asgiref            3.2.10
......
WTForms            2.3.1
xlrd               1.2.0
zipp               3.1.0
WARNING: You are using pip version 20.1.1; however, version 20.2.2 is available.
You should consider upgrading via the '/Library/Developer/CommandLineTools/usr/bin/python3 -m pip install --upgrade pip' command.

通过pip3 show 库名,打印库的信息,这里以xlrd为例。打印如下:

xxxx@MacBook-Pro ~ % pip3 show xlrd
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
Name: xlrd
Version: 1.2.0
Summary: Library for developers to extract data from Microsoft Excel (tm) spreadsheet files
Home-page: http://www.python-excel.org/
Author: John Machin
Author-email: sjmachin@lexicon.net
License: BSD
Location: /Users/xxxx/Library/Python/3.7/lib/python/site-packages
Requires: 
Required-by:

site-package位置在Location:

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值