I did a simple pip install psycopg2 on mac system. It installed fine, but when I try to use psycopg2 I get the error:
Reason: Incompatible library version: _psycopg.so requires version 1.0.0 or later, but libssl.0.9.8.dylib provides version 0.9.8
pip freeze shows psycopg2==2.4.5 just right. I have installed psycopg2 on several virtualenvs but this is the first time I am seeing such error. I tried uninstalling and reinstalling, same results. Please help
The accepted answer here is correct (except I think it must be ln -fs , in fact I think it might even risk destabalizing your OS if not (?)). After bumping into this and dealing with it I just want to collect the full solution for this issue and the other lib problem (libcrypto.1.0.0.dylib) you will run into for Postgres 9.* on Mountain Lion and Snow Leopard, and perhaps other systems. This also blocked me from running psql, which complained about the same two libs.
Essentially there are two later-version libs needed in /usr/lib, libssl and libcrypto. You can find the needed versions of these libs in the Postgres lib directory.
If you're OSX and installed the Enterprise DB version of Postgres this will be in /Library/PostgreSQL/9.2/lib.
For other install types of Postgres, look for the lib directory inside the Postgress install directory, e.g., for Postgress.app, find the lib directory in /Applications/Postgres.app/Contents/MacOS/lib,
for brew somewhere in /usr/local/Cellar,
on *nix, wherever your install is. But see first on *nix if your distro has later versions just through the package manager.
First copy the latest of these two libs from the Postgres lib directory to /usr/lib:
sudo cp /Library/PostgreSQL/9.2/lib/libssl.1.0.0.dylib /usr/lib
sudo cp /Library/PostgreSQL/9.2/lib/libcrypto.1.0.0.dylib /usr/lib
Then update (or create) the /usr/lib symlinks for this libs. Either way the command is ln -fs:
sudo ln -fs /usr/lib/libssl.1.0.0.dylib /usr/lib/libssl.dylib
sudo ln -fs /usr/lib/libcrypto.1.0.0.dylib /usr/lib/libcrypto.dylib
Should be fixed. Pretty sure ln -fs is better than deleting the symlink and remaking it, so there is less chance of libssl being unfindable by something that needs it for the time it is not present (it does the same thing; it first deletes the symlink if it's already there, just faster than you can type it). Always wary of messing around on /usr/lib.
Worked for me:
env LDFLAGS='-L/usr/local/lib -L/usr/local/opt/openssl/lib
-L/usr/local/opt/readline/lib' pip install psycopg2
Source: Can't install psycopg2 with pip in virtualenv on Mac OS X 10.7
I ran into a similar problem after upgrading to Mountain Lion.
Instead of copying libssl.* files per Slack's suggestion, make sure that /usr/lib/libssl.dylib is actually a soft link to the most up-to-date version of the library.
E.g., on my machine, ls -l /usr/lib/libssl* gives:
lrwxr-xr-x 1 root wheel 46B Jun 27 15:24 /usr/lib/libssl.1.0.0.dylib -> /Library/PostgreSQL/9.1/lib/libssl.1.0.0.dylib
lrwxr-xr-x 1 root wheel 27B Jul 30 10:31 /usr/lib/libssl.dylib -> /usr/lib/libssl.1.0.0.dylib
If libssl.dylib doesn't link to the version that the error version mentions, make sure you have that version of the library, and then make sure /usr/lib/libssl.dylib points to it, and not an older version.
If the link doesn't exist, create it like so
sudo ln -s library_to_link_to link_to_create
using, of course, the proper locations for your machine. For me, this turned out to be:
sudo ln -s /usr/lib/libssl.1.0.0.dylib /usr/lib/libssl.dylib
Edit:
It seems like some are having trouble with part of my solution. Namely, deleting these important libraries even temporarily causes problems with the operating system.
Per Purrell's answer, make sure you include the -fs flags when you use the ln command, which helps ensure that the libraries don't go missing for a short period of time. E.g.,
sudo ln -fs /usr/lib/libssl.1.0.0.dylib /usr/lib/libssl.dylib
sudo ln -fs /usr/lib/libcrypto.1.0.0.dylib /usr/lib/libcrypto.dylib
On OSX 10.11, El Capitan, solution with replacing symlinks reported Operation not permitted. Solution that worked for me was using brew and setting up DYLD_LIBRARY_PATH. So:
brew install openssl
Find where openssl brew libs are located (brew --prefix openssl can help), start searching from directory /usr/local/Cellar/openssl. In my case it is in /usr/local/Cellar/openssl/1.0.2d_1/lib
Finally set up DYLD_LIBRARY_PATH, i.e. add a line like this into .bash_profile :
# replace location of lib files with folder name you found in previous step
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/Cellar/openssl/1.0.2d_1/lib
UPDATE: More generic/better alternatives are (thanks to #dfrankow):
to use brew to find openssl location (a note, brew can be slow): DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$(brew --prefix openssl)/lib
for development purposes maybe it is better to use DYLD_FALLBACK_LIBRARY_PATH instead - check this
Restart shell, or just source ~/.bash_profile, reinstall psycopg2:
pip uninstall psycopg2
pip install psycopg2
and test if it works:
$ python -c"import psycopg2 ; print('psycopg2 is now ok')"
When trying to do a syncdb Postgres 9.1 and /psycopg2/_psycopg.so added a further error:
Library not loaded: #loader_path/../lib/libcrypto.dylib
Referenced from: /usr/lib/libpq.5.dylib
Reason: Incompatible library version: libpq.5.dylib requires version 1.0.0 or later, but libcrypto.0.9.8.dylib provides version 0.9.8
Solved by copying these six (6) files from:
LOCAL:/Library/PostgreSQL/9.1/lib/
libssl.1.0.0.dylib
libssl.a
libssl.dylib
libcrypto.1.0.0.dylib
libcrypto.a
libcrypto.dylib
to: LOCAL:/usr/lib
This was on Mac OSx 10.8.1 with a web in a virtualenv (1.8.2) and pgAdmin (1.14.3). Inside the virtualenv is:
Django==1.4
psycopg2==2.4.5
... etc... and now back to normal.
For me, the libcryto and libss version 1.0.0 resides below:
/Library/PostgreSQL/9.1/lib/libcrypto.1.0.0.dylib
/Library/PostgreSQL/9.1/lib/libssl.1.0.0.dylib
so the commands that fix my problem is:
sudo ln -fs /Library/PostgreSQL/9.1/lib/libssl.1.0.0.dylib /usr/lib/libssl.dylib
sudo ln -fs /Library/PostgreSQL/9.1/lib/libcrypto.1.0.0.dylib /usr/lib/libcrypto.dylib
my friend, just copy libssl.* files from PostgreSQL lib directory to /usr/lib and relaunch your application in this case all things will be perfect ^_^
For me on Mavericks, it worked to just copy the two dylib and relaunch Python:
cp /Library/PostgreSQL/9.3/lib/libssl.1.0.0.dylib /usr/lib/
cp /Library/PostgreSQL/9.3/lib/libcrypto.1.0.0.dylib /usr/lib/
If you are uncomfortable copying libraries into your system directory, you can use the DYLD_LIBRARY_PATH environment variable to force the OS to search Postgres's library directory for libssl. E.g.:
$ DYLD_LIBRARY_PATH=/Library/PostgreSQL/9.4/lib pip install psycopg2
(documented under the dyld man page).
I had similar problem on my Mac OS High Sierra.
ImportError: dlopen(/Users/chicha/Projects/CTMR/sample_registration/romans_env/lib/python3.7/site-packages/psycopg2/_psycopg.cpython-37m-darwin.so, 2): Library not loaded: /opt/local/lib/libssl.1.0.0.dylib
But after "pip install postgres" it's work fine.
According to pip show - "postgres is a high-value abstraction over psycopg2".
While installing it's also installed psycopg2-binary and psycopg2-pool.
So, all together they have repaired the situation somehow.
Related
I have tried many ways of installing python3.7.6 on centos 7.
Regardless of what I do, I always get the error that the SSL module is not available.
I have tried basic install guides such as https://tecadmin.net/install-python-3-7-on-centos/
(short story: yum install openssl-devel, configure, make install)
One with manual/updated changes to the build files (https://joshspicer.com/python37-ssl-issue)
I've downloaded and built openssl myself, then tried to configure/build python with --with-openssl
No go.
Any other ideas?
If it were really this hard, no one would be using it, so I must have something special going on.
Ok, here's what finally worked for me.
I think the key to success was updating LD_LIBRARY_PATH and PATH to include openssl as I went.
Install and build openssl.
OpenSSL 1.1.1d 10 Sep 2019
cloned openssl repo
Pulled out latest(?) 1.1 branch
git checkout OpenSSL_1_1_1d -b 1_1_1d
./config --prefix=/opt/openssl
make
make install
Add /opt/openssl/lib to your LD_LIBRARY_PATH env var
Add /opt/openssl/bin to your PATH
Install and build python-3.7.6
I installed with --prefix=/opt/python-3.7.6
./configure --prefix=/opt/python-3.7.6 --enable-optimizations --with-openssl=/opt/openssl
make
make install
Add /opt/python-3.7.6/lib to your LD_LIBRARY_PATH env var
Add /opt/python-3.7.6/bin to your PATH
Final Config
LD_LIBRARY_PATH=/opt/openssl/lib:/opt/python-3.7.6/lib:
PATH=/opt/openssl/bin:/opt/python-3.7.6/bin:/opt/idea/latest/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
seeing your post i decided to stop trying to install 3.7 (already half an hour of head banging) and went for 3.6 using IUS. however, when i checked the version i had just installed, i saw this:
$ python3 -V
Python 3.7.4
so it looks like i got 3.7 even though this is the yum command i used:
$ yum install python36
anyway, it worked for me, perhaps it will work for you? a little bizarre, imo.
First off, yeah, I've already seen this:
pip install mysql-python fails with EnvironmentError: mysql_config not found
The problem
I am trying to use Django on a Google App Engine project. However, I haven't been able to get started as the server fails to start properly due to:
ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb
I did some research and it all pointed to having to install Mysql-python, as apparently it isn't on my system. I actually tried uninstalling it and got this:
Cannot uninstall requirement mysql-python, not installed
Whenever I actually do try to install via:
sudo pip install MySQL-python
I get an error stating:
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
I've already tried running:
export PATH=$PATH:/usr/local/mysql/bin
but that didn't seem to help, as I ran the installation command again and it still failed.
Any ideas?
Please note I'm not in a virtualenv.
Ok, well, first of all, let me check if I am on the same page as you:
You installed python
You did brew install mysql
You did export PATH=$PATH:/usr/local/mysql/bin
And finally, you did pip install MySQL-Python (or pip3 install mysqlclient if using python 3)
If you did all those steps in the same order, and you still got an error, read on to the end, if, however, you did not follow these exact steps try, following them from the very beginning.
So, you followed the steps, and you're still geting an error, well, there are a few things you could try:
Try running which mysql_config from bash. It probably won't be found. That's why the build isn't finding it either. Try running locate mysql_config and see if anything comes back. The path to this binary needs to be either in your shell's $PATH environment variable, or it needs to be explicitly in the setup.py file for the module assuming it's looking in some specific place for that file.
Instead of using MySQL-Python, try using 'mysql-connector-python', it can be installed using pip install mysql-connector-python. More information on this can be found here and here.
Manually find the location of 'mysql/bin', 'mysql_config', and 'MySQL-Python', and add all these to the $PATH environment variable.
If all above steps fail, then you could try installing 'mysql' using MacPorts, in which case the file 'mysql_config' would actually be called 'mysql_config5', and in this case, you would have to do this after installing: export PATH=$PATH:/opt/local/lib/mysql5/bin. You can find more details here.
Note1: I've seen some people saying that installing python-dev and libmysqlclient-dev also helped, however I do not know if these packages are available on Mac OS.
Note2: Also, make sure to try running the commands as root.
I got my answers from (besides my brain) these places (maybe you could have a look at them, to see if it would help): 1, 2, 3, 4.
I hoped I helped, and would be happy to know if any of this worked, or not. Good luck.
I had been debugging this problem forever - 3 hours 17 mins. What particularly annoyed me was that I already had sql installed on my system through prior uni work but pip/pip3 wasn't recognising it. These threads above and many other I scoured the internet for were helpful in eluminating the problem but didn't actually solve things.
ANSWER
Pip is looking for mysql binaries in the Homebrew Directory which is located relative to Macintosh HD #
/usr/local/Cellar/
so I found that this requires you making a few changes
step 1: Download MySql if not already done so https://dev.mysql.com/downloads/
Step 2: Locate it relative to Macintosh HD and cd
/usr/local/mysql/bin
Step 3: Once there open terminal and use a text editor of choice - I'm a neovim guy myself so I typed (doesn't automatically come with Mac... another story for another day)
nvim mysql_config
Step 4: You will see at approx line 112
# Create options
libs="-L$pkglibdir"
libs="$libs -l "
Change to
# Create options
libs="-L$pkglibdir"
libs="$libs -lmysqlclient -lssl -lcrypto"
*you'll notice that this file has read-only access so if your using vim or neovim
:w !sudo tee %
Step 5: Head to the home directory and edit the .bash_profile file
cd ~
Then
nvim .bash_profile
and add
export PATH="/usr/local/mysql/bin:$PATH"
to the file then save
Step 6: relative to Macintosh HD locate paths and add to it
cd /private/etc/
then
nvim paths
and add
/usr/local/mysql/bin
*you'll again notice that this file has read-only access so if your using vim or neovim
:w !sudo tee %
then
cd ~
then refresh the terminal with your changes by running
source .bash_profile
Finally
pip3 install mysqlclient
And Viola. Remember it's a vibe.
If you don't want to install full mysql, we can fix this by just installing mysql-client
brew install mysql-client
Once cmd is completed it will ask to add below line to ~/.bash_profile:
echo 'export PATH="/usr/local/opt/mysql-client/bin:$PATH"' >> ~/.bash_profile
Close terminal and start new terminal and proceed with pip install mysqlclient.
I am running Python 3.6 on MacOS Catalina. My issue was that I tried to install mysqlclient==1.4.2.post1 and it keeps throwing mysql_config not found error.
This is the steps I took to solve the issue.
Install mysql-connector-c using brew (if you have mysql already install unlink first brew unlink mysql) - brew install mysql-connector-c
Open mysql_config and edit the file around line 112
# Create options
libs="-L$pkglibdir"
libs="$libs -lmysqlclient -lssl -lcrypto"
brew info openssl - this will give you more information on what needs to be done about putting openssl in PATH
in relation to step 3, you need to do this to put openssl in PATH - echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
for compilers to find openssl - export LDFLAGS="-L/usr/local/opt/openssl/lib"
for compilers to find openssl - export CPPFLAGS="-I/usr/local/opt/openssl/include"
Also this happens when I was installing mysqlclient,
$ pip install mysqlclient
As user3429036 said,
$ brew install mysql
If you have installed mysql using Homebrew by specifying a version then mysql_config would be present here. - /usr/local/Cellar/mysql#5.6/5.6.47/bin
you can find the path of the sql bin by using ls command in /usr/local/ directory
/usr/local/Cellar/mysql#5.6/5.6.47/bin
Add the path to bash profile like this.
nano ~/.bash_profile
export PATH="/usr/local/Cellar/mysql#5.6/5.6.47/bin:$PATH"
This answer is for MacOS users who did not install from brew but rather from the official .dmg/.pkg. That installer fails to edit your PATH, causing things to break out of the box:
All MySQL commands like mysql, mysqladmin, mysql_config, etc cannot be found, and as a result:
the "MySQL Preference Pane" fails to appear in System Preferences, and
you cannot install any API that communicates with MySQL, including mysqlclient
What you have to do is appending the MySQL bin folder (typically /usr/local/mysql/bin in your PATH by adding this line in your ~/.bash_profile file:
export PATH="/usr/local/mysql/bin/:$PATH"
You should then reload your ~/.bash_profile for the change to take effect in your current Terminal session:
source ~/.bash_profile
Before installing mysqlclient, however, you need to accept the XcodeBuild license:
sudo xcodebuild -license
Follow their directions to sign away your family, after which you should be able to install mysqlclient without issue:
pip install mysqlclient
After installing that, you must do one more thing to fix a runtime bug that ships with MySQL (Dynamic Library libmysqlclient.dylib not found), by adding this line to your system dynamic libraries path:
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/:$DYLD_LIBRARY_PATH
brew install mysql added mysql to /usr/local/Cellar/..., so I needed to add :/usr/local/Cellar/ to my $PATH and then which mysql_config worked!
The problem in my case was that I was running the command inside a python virtual environment and it didn't had the path to /usr/local/mysql/bin though I have put it in the .bash_profile file. Just exporting the path in the virtual env worked for me.
For your info sql_config resides inside bin directory.
Install brew or apt-get is also not easy for me so I downloaded mysql via: https://dev.mysql.com/downloads/connector/python/, installed it. So I can find mysql_config int this directory: /usr/local/mysql/bin
the next step is:
export PATH=$PATH:/usr/local/mysql/bin
pip install MySQL-python==1.2.5
I can't seem to find documentation on this. Matplotlib says to run:
sudo yum install python-matplotlib
which installs all the dependancies and this version of matplotlib successfully:
python-matplotlib.x86_64 0:0.99.1.2-1.6.amzn1
However, I use python2.7, separately installed. The original (and still existing) python2.6 now imports matplotlib successfully. Is there a related matplotlib package on RedHat for python2.7? I don't know how to use this page on python-matplotlib packages.
Other info:
which python2.6 returns /usr/bin/python2.6
which python returns /usr/bin/python.
cat /proc/version returns
Linux version 3.14.23-22.44.amzn1.x86_64 ... (Red Hat 4.8.2-16) (GCC) ...
Something else I tried:
I also tried to use pip2.7 instead, installed all the dependancies, and it broke on this issue concerning permissions. The solution is to reset the permissions of the problem file with:
chmod o+x /path/to/file
However, it's a temporary copied file. :( During the install of matplotlib it recopies this file over, so I can't set permissions on it. Here is the place it is broken:
g++ ... -lpython2.7 -o build/lib.linux-x86_64-2.7/matplotlib/backends/_backend_agg.so
running install_lib
copying pylab.py -> /usr/lib64/python2.7/site-packages
error: [Errno 13] Permission denied: '/usr/lib64/python2.7/site-packages/pylab.py'
This doesn't seem like the right way to do it, it's too cobbled together.
Question asked first at the Unix&Linux stackexchange.
I built from source. :( Surprisingly not that difficult, but ran into a lot of problems doing the interactive part (Redhat 4 is too old to have packages for most things that let you do interactive backends, I need a newer machine).
# get matplotlib
wget https://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.4.3/matplotlib-1.4.3.tar.gz
#uncompress
tar xvzf matplotlib-1.4.3.tar.gz
# open build install
# read INSTALL file for more instructions
cd matplotlib-1.4.3
python setup.py build
# actually installing needed superuser privileges
sudo python setup.py install
Hope this saves time for anyone else with a similar setup.
On centos 7 I installed python 3.6.1, into /usr/local
This also automatically installed pip
Then I ran sudo /usr/local/bin/pip3.6 install matplotlib
and it was all good
I spent the past couple of days trying to get opencv to work with my Python 2.7 install. I kept getting an error saying that opencv module was not found whenever I try "import cv".
I then decided to try installing opencv using Macports, but that didn't work.
Next, I tried Homebrew, but that didn't work either.
Eventually, I discovered I should modify the PYTHONPATH as such:
export PYTHONPATH="/usr/local/lib/python2.6/site-packages/:$PYTHONPATH"
My problem is that I didn't find /usr/local/lib/python2.*...etc
The folder simply doesn't exist
So my question is this:
How do I properly install Python on OS X Snow Leopard for it to work with opencv?
Thanks a lot,
I spent a couple days on this myself. For me, the problem was that that OpenCV installer was not finding the right python installation. It was defaulting to the MacOS-installed version despite the fact that I had upgraded python with homebrew and was using a virtualenv for python. I have collected most of my setup in a gist here:
https://gist.github.com/4150916
Use homebrew to get all the dependencies, but then download the OpenCV tarball and compile yourself being sure to specify all the python related configuration options.
Assuming a virtualenv named 'opencv'...
cd OpenCV-2.4.3/
mkdir release
cd release
cmake -D PYTHON_EXECUTABLE=$WORKON_HOME/opencv/bin/python \
-D PYTHON_PACKAGES_PATH=$WORKON_HOME/opencv/lib/python2.7/site-packages \
-D INSTALL_PYTHON_EXAMPLES=ON\
-D PYTHON_INCLUDE_DIR=/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Headers\
-D PYTHON_LIBRARY=/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib\
..
make -j8
make install
You need to install the module using your python2.7 installation. Pointing your PYTHONPATH at stuff installed under 2.6 to run under 2.7 is a Bad Idea.
Depending on how you want to install it, do something like python2.7 setup.py or easy_install-2.7 opencv to install.
fwiw, on OS X the modules are usually installed under /System/Library/Frameworks/Python.framework/ but you should almost never need to know where anything installed in your site packages is physically located; if Python can't find them without help you've installed them wrong.
Installing OpenCV with Homebrew
brew tap homebrew/homebrew-science
brew install opencv
Setting up Python
Depending on your install location - OS X Default
cd /Library/Python/2.7/site-packages/
or - Homebrew Python
cd /usr/local/lib/python2.7
Then create the symbolic link
ln -s /usr/local/Cellar/opencv/2.4.9/lib/python2.7/site-packages/cv.py cv.py
ln -s /usr/local/Cellar/opencv/2.4.9/lib/python2.7/site-packages/cv2.so cv2.so
The above method sourced from a blog post.
I searched and tried installing opencv3 with python3 for 3 days. Some links suggest for Brew and some virtual env, some say install xcode but all failed in my case.
Dont use linux steps to instal opencv-python on Mac. Problem with Mac is Python 2.7 is already installed by Mac. On top of that installing and linking all site-packages is little problematic and we end up with errors.
I'll share what I did: easy steps to install complete package opencv3, numpy, matplotlib, notebook, spyder etc.. on Mac.
Install anaconda, it creates a directory and install everything inside that
use this link -> https://www.continuum.io/downloads
download command-line-install
After download, goto terminal and download location of anaconda.
$ bash Anaconda3-4.3.0-MacOSX-x86_64.sh
Installation will ask you to append path to .bash_profile >> say yes
Goto home directory, run .bash_profile
$ source .bash_profile
check python, should be pointing to
$ which python
$ /.../anaconda/bin/python
Last step
$ pip install opencv-pyhton
$ python
$ import cv2
if no errors, we are good to go.
I've tried to compile Python 2.7 on Ubuntu 10.4, but got the following error message after running make:
Python build finished, but the necessary bits to build these modules were not found:
_bsddb bsddb185 sunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
What packages do I need? (setup.py was not helpful)
Assuming that you have all the dependencies installed (on Ubuntu that would be bunch of things like sudo apt-get install libdb4.8-dev and various other -dev packages, then this is how I build Python.
tar zxvf Python-2.7.1.tgz
cd Python-2.7.1
# 64 bit self-contained build in /opt
export TARG=/opt/python272
export CC="gcc -m64"
export LDFLAGS='-Wl,-rpath,\$${ORIGIN}/../lib -Wl,-rpath-link,\$${ORIGIN}/../lib -Wl,--enable-new-dtags'
./configure --prefix=$TARG --with-dbmliborder=bdb:gdbm --enable-shared --enable-ipv6
make
make install
The only modules that don't build during make are:
_tkinter - I don't do GUI apps and would use wxWindows if I did
bsddb185 - horribly obsolete version of bdb
dl - deprecated in 2.6
imageop - deprecated in 2.6
sunaudiodev - obsolete interface to some SparcStation device I think
Next I collect any .so files that are not already in the Python install directories and copy them over:
# collect binary libraries ##REDO THIS IF YOU ADD ANY ADDITIONAL MODULES##
cd /opt/python272
find . -name '*.so' | sed 's/^/ldd -v /' >elffiles
echo "ldd -v bin/python" >>elffiles
chmod +x elffiles
./elffiles | sed 's/.*=> //;s/ .*//;/:$/d;s/^ *//' | sort -u | sed 's/.*/cp -L & lib/' >lddinfo
# mkdir lib
chmod +x lddinfo
./lddinfo
And then add setuptools for good measure
#set the path
export PATH=/opt/python272/bin:$PATH
#install setuptools
./setuptools-0.6c11-py2.7.egg
At this point I can make a tarball of /opt/python272 and run it on any 64-bit Linux distro, even a stripped down one that has none of the dependencies installed, or a older distro that has old obsolete versions of the dependencies.
I also get pip installed but at this point there is a gap in my notes due to some failed struggles with virtualenv. Basically virtualenv does not support this scenario. Presumably I did easy_install pip and then:
export LD_RUN_PATH=\$${ORIGIN}/../lib
pip install cython
pip install {a whole bunch of other libraries that I expect to use}
After I'm done installing modules, I go back and rerun the commands to collect .so files, and make a new tarball. There were a couple of packages where I had to muck around with LDFLAGS to get them to install correctly, and I haven't done enough thorough testing yet, but so far it works and I'm using this Python build to run production applications on machines that don't have all the support libraries preinstalled.
Those are older, (mostly depreciated) modules that you probably won't use. You should be able to safely ignore the warnings.
The one that you may want to worry about trying to fix is _bsddb, which should go away once you install Berkeley DB 4.8... I'm not sure if it's in the Ubuntu repos or not. (edit: apparently it's the db package)
bsddb185 is an older version of the Oracle Berkley Database module. You can safely ignore it as far as I know.
sunaudiodev is depreciated, undocumented, I doubt you'd ever need to use it anyway. You should be able to safely ignore it.
Hope that helps a bit, anyway...
sudo apt-get build-dep python2.6 python-gdbm python-bsddb3 (Use python2.7 on maverick).
For more information, see this answer. Also look at this page, which applies equally for building on Lucid.