One - One Code All

Blog Content

mac python查找第三方库路径site-packages

Python Linux-Mac   2019-04-14 16:13:43

python第三方包都安装到了site-packages目录下了。 我们可以通过下面的python代码来找到它的位置:


import os

os.path.dirname(os.__file__)


>>> import os

>>> os.path.dirname(os.__file__)

'/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7'


>>> import numpy

>>> numpy.__file__

'/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/__init__.py'



这个路径在不同操作系统下会有不同的值。


$ ls /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/



上一篇:mac上python连接SSL报错certificate verify failed: unable to get local issuer certificate _ssl.c:1123
下一篇:pandas dataframe多列批量数据类型转换astype

The minute you think of giving up, think of the reason why you held on so long.