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: [email protected]
License: BSD
Location: /Users/xxxx/Library/Python/3.7/lib/python/site-packages
Requires: 
Required-by:

site-package位置在Location:

猜你喜欢

转载自blog.csdn.net/qq_24256877/article/details/108327246
今日推荐