/usr/bin/ld: cannot find -lpython2.7 /usr/bin/ld: cannot find -lpython2.7 linux linux

/usr/bin/ld: cannot find -lpython2.7


It can't find the Python library, not the executable. Run locate libpython2.7.a to see where your Python library is located, and add it to the library path (e.g. if it is in /opt/python2.7/lib, you want to call LDFLAGS="-L/opt/python2.7/lib" make).

The @ symbol means the file is a symbolic link; * means it's executable (these are produced by ls -F, which you might have as an alias).


The above solution didn't quite do it for me as I was using pip to install mysql-python, but was definitely a big push in the right direction. For the benefit of anyone who lands here from Google in the same situation as me, my solution was to symlink libpython2.7.a from the python installation directory to the lib dir:

ln -s /opt/python2.7.1/lib/python2.7/config/libpython2.7.a

/usr/local/lib/

pip install mysql-python worked without any issues afterwards.