How do I stop Python install on Mac OS X from putting things in my home directory?
I'm trying to install Python from source on my Mac. (OS X 10.6.2, Python-2.6.5.tar.bz2) I've done this before and it was easy, but for some reason, this time after ./configure
, and make
, the sudo make install
puts things some things in my home directory instead of in /usr/local/... where I expect. The .py files are okay, but not the .so files...
RobsMac Python-2.6.5 $ sudo make install
[...] /usr/bin/install -c -m 644 ./Lib/anydbm.py /usr/local/lib/python2.6 /usr/bin/install -c -m 644 ./Lib/ast.py /usr/local/lib/python2.6 /usr/bin/install -c -m 644 ./Lib/asynchat.py /usr/local/lib/python2.6 [...] running build_scripts running install_lib creating /Users/rob/Library/Python creating /Users/rob/Library/Python/2.6 creating /Users/rob/Library/Python/2.6/site-packages copying build/lib.macosx-10.4-x86_64-2.6/_AE.so -> /Users/rob/Library/ Python/2.6/site-packages copying build/lib.macosx-10.4-x86_64-2.6/_AH.so -> /Users/开发者_如何学Gorob/Library/ Python/2.6/site-packages copying build/lib.macosx-10.4-x86_64-2.6/_App.so -> /Users/rob/Library/ Python/2.6/site-packages [...]Later, this causes imports that require those .so files to fail. For example...
RobsMac Python-2.6.5 $ python
Python 2.6.5 (r265:79063, Apr 28 2010, 13:40:18) [GCC 4.2.1 (Apple Inc. build 5646) (dot 1)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import zlib Traceback (most recent call last): File "", line 1, in ImportError: No module named zlibAny ideas what is wrong?
thanks, Rob
Doh. I've answered my own question. Recently I created a ~/.pydistutils.cfg file, for some stupid reason. I forgot to delete that file. It's contents were:
[install]
install_lib = ~/Library/Python/$py_version_short/site-packages
install_scripts = ~/bin
make install
calls setup.py
, and this file was overriding the normal setup.py
behavior.
Rob
In general, installing Python (or anything directly from the source) when it is already available on your system or when there are package managers that will install it for you, is not a very good idea. I strongly advise you against installing Python manually... Mac OS X 10.6 Snow Leopard comes with Python 2.6 out of the box; if you want a newer version of Python 2.6, then you should install MacPorts, and use:
sudo port install python26 python_select
You can then use the python_select
to toggle between the system's version and MacPort's version.
If you are determined to install manually from the source, though, the way to do it would be to run "make distclean" (or untar the code separately again), then run "./configure --help" for a full list of configuration options. It is possible that on Mac OS X, it defaults to something other than /usr/local, in which case you could force it to install in that location by invoking configure with "./configure --prefix=/usr/local".
Have you checked the parameters or variables make expects? There probably is a make variable you can use to override that behavior. In any case, have you tried MacPorts? It may be a better solution to what you are trying to accomplish.
精彩评论