[Tutor] site-packages

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Sun Mar 26 08:16:35 CEST 2006



On Sat, 25 Mar 2006, linda.s wrote:

> I downloaded some modules and were told to put under
> *\Python24\Lib\site-packages

Hi Linda,

Out of curiosity, which module?  If we're being asked to copy files
manually into site-packages, we should do a double check on this, because
that's a slightly odd thing to do these days.  A well-packaged module uses
the Distutils system:

    http://docs.python.org/lib/module-distutils.html

and will typically include a 'setup.py' program that knows how to relocate
that module to the right location, so that you don't have to worry about
the details.


> I use mac machine and run Python 2.4 but why i could not find any folder
> named Python24. Also, my Mac machine has a default Python 2.3, I do not
> see any folder named Python2.3

If you really need to do this, run Python 2.4 and then do the following:

######
import distutils.sysconfig
print distutils.sysconfig.get_python_lib()
######

This should print out the path that you're looking for.  For example, on
my Python 2.3 installation (the default on Mac OS X):

######
mumak:~ dyoo$ python
Python 2.3.5 (#1, Mar 20 2005, 20:38:20)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1809)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import distutils.sysconfig
>>> distutils.sysconfig.get_python_lib()
'/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages'
######

So that's the directory that third-party libraries will live on my system.


But again, please tell us what modules you're trying to install, before
you go ahead and copy things over.  Manually having to copy these files
into site-packages/ is bug-prone.  You shouldn't have to do this if the
module developers have done their due dilligence by including a "setup.py"
distutils installer program.



More information about the Tutor mailing list