I am trying to build Python from source and need to include the SSL module for my web scraper to work with it.
I ran into the problem of SSL not being found, so I downloaded and built OpenSSL from source. The problem is, I need to install the development libraries along with OpenSSL in order for Python to run the -lssl
parameter correctly when running make
. I can't seem to find any documentation on how to build OpenSSL with the development libs, even though I'm sure it's got to be something simple I'm just missing.
I must do this from source; with no package managers. I have my reasons.
EDIT: I have changed a few of the python configuration settings to try and fix the problem, and this is the compile error I am getting now:
gcc -pthread -Xlinker -export-dynamic -o python \
Modules/python.o \
libpython2.7.a -lpthread -ldl -lutil -L/home/[username]/openssl-src -lssl -lcrypto -lm
libpython2.7.a(posixmodule.o)(.text+0x4016): In function
posix_tmpnam':<br />
./Modules/posixmodule.c:7346: warning: the use of
tmpnam_r' is dangerous, better use mkstemp'
libpython2.7.a(posixmodule.o)(.text+0x3f76): In f开发者_如何学Gounction
posix_tempnam':
./Modules/posixmodule.c:7301: warning: the use of tempnam' is dangerous, better use
mkstemp'
./python: error while loading shared libraries: libssl.so.1.0.0: cannot open shared object file: No such file or directory
make: * [sharedmods] Error 127
The "no such file or directory" is being thrown looking for a file that does exist in the /home/[username]/openssl-src
directory.
The default OpenSSL build should install the appropriate header files and libraries using make install
, just make sure to provide the right prefix to the configure script (e.g., ./configure --prefix=/usr
).
If this fails, please post the exact error that gcc shows.
By the way, please consider using an automated tool such as buildout for building Python. I think the standard recipes take care of SSL support (possibly even downloading and compiling OpenSSL), although I am not certain about this.
This answer doesn't EXACTLY answer my question, but I did find out what I needed to know so I will post it here. I had to change the location of the SSL files it was looking for to just /usr
rather than /usr/local
. RedHat by default has all the shared libraries in /usr/lib
rather than /usr/local/lib
, which is where it was looking by default.
in the Bourne shell (/bin/sh or /bin/bash):
$ LD_LIBRARY_PATH=/usr/local/lib
$ export LD_LIBRARY_PATH
$ make
in the C-shell (/bin/csh or /bin/tcsh):
% setenv LD_LIBRARY_PATH /usr/local/lib
% make
精彩评论