Location of global libraries for Python on Mac?

时光毁灭记忆、已成空白 提交于 2020-01-09 09:05:27

问题


I'm fighting with installation SIP for Python on Mac OS X. Finally after compilation and installation when I run console form folder of SIP (locally) I can import sipconfig, but when I`m in other folder I cant - there is no module called sipconfig.

My question is - Where is folder to which I have to copy modules if I want to have them available globally (like "import os"), or how I can check it, because location "/Library/Python/2.6/site-packages/" doesn`t work.


回答1:


Try checking your python's sys.path list with:

import sys
print(sys.path)



回答2:


A simple method I use is to ask a module where it is:

import os
print(os.__file__)



回答3:


/Library/Python/2.6/site-packages/ is indeed the right place (assuming it's Mac OS 10.6 "Snow Leopard" - you didn't mention which).

As @diatoid mentioned, check your system path (and make sure you're actually using Python 2.6 by running python -V).




回答4:


For Python 3.5, It's /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages



来源:https://stackoverflow.com/questions/2741496/location-of-global-libraries-for-python-on-mac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!