Mac下查找python的安裝位置以及第三方庫

由於有時候會寫一個工具放在lib下,對於windows是很好找python安裝包的地址以及lib  和 site-packagespython

可是對於mac來講倒是不太容易,現提供方法以下:windows

親測可用工具

1.首先找site-packagesspa

import sys
print(sys.path)
/usr/local/bin/python3.7 /Users/tuyoo/Documents/pytext/test02/other_file/a_011.py
['/Users/tuyoo/Documents/pytext/test02/other_file', '/Users/tuyoo/Documents/pytext/test02', '/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python37.zip', '/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7', '/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload', '/usr/local/lib/python3.7/site-packages']
/usr/local/bin/python3.7 /Users/tuyoo/Documents/pytext/test02/other_file/a_011.py
['/Users/tuyoo/Documents/pytext/test02/other_file', 
'/Users/tuyoo/Documents/pytext/test02', 
'/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python37.zip', 
'/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7', 
'/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload', 
'/usr/local/lib/python3.7/site-packages']   #site-packages 所在

想進入到該路徑下可根據找lib方法找這個文件code

 

 

 

2.找libblog

咱們從上一條數據裏摘抄出和lib相關的ip

'/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python37.zip',
 '/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7', '
/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload',

能夠查一下路徑下的文件:(建議拿windows路徑下的文件作個對比找到存儲位置,好比win下 py下lib下文件有哪些)it

方法1:用終端進入到指定路徑下,查看文件io

方法2:使用訪達     快捷鍵:command + Shift + Gclass

       (1)打開訪達    (2)操做快捷鍵輸入路徑    (3)前往    (4)查看文件

      

 

      通過查找,發現此路徑下文件與Windows下py自導lib文件一致

備註:把寫好的工具拽到lib下,放在lib之後能夠經過:import 模塊」導入不報錯 就是成功

相關文章
相關標籤/搜索