36

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.

Mike Pennington
43.3k22 gold badges140 silver badges191 bronze badges
asked Apr 29, 2010 at 23:53
1
  • If /Library/Python/2.6/site-packages doesn't work, then you are probably using a version of Python other than the system Python. Commented May 4, 2010 at 3:19

5 Answers 5

68

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

import sys
print(sys.path)
Ivelin
13.6k6 gold badges40 silver badges37 bronze badges
answered Apr 30, 2010 at 0:16
Sign up to request clarification or add additional context in comments.

Comments

32

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

import os
print(os.__file__)
answered Jun 8, 2011 at 12:55

Comments

11

/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).

answered Jun 8, 2011 at 12:52

Comments

11

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

answered Jul 10, 2017 at 22:15

1 Comment

Make sure you aren't using your user Library and use the Macintosh HD Library, this caught me out.
0

You can designate an additional locations when python starts up by setting the environmental variable PYTHONPATH.

If you add to ~/.bashrc or ~/.zscrc (depending on your default shell) something like:

PYTHONPATH=/Library/MyPyhonPackages:/Another/Location; export PYTHONPATH

Then those locations will be added to "sys.path" whenever python starts up.

This will give you additional places to store your own packages or modules.

answered Jan 27, 2021 at 9:17

2 Comments

Welcome to the StackOverflow! Your answer is not really relevant to the question.
The reason I added it here was because this is where I landed when looking for how to add locations to the global list and thought this might be useful to others looking for this. I apologise unreservidly if it was not appropriate to do so.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.