21

The Google App Engine Launcher tells me:

WARNING appengine_rpc.py:399 ssl module not found. Without the ssl module, the identity of the remote host cannot be verified, and connections may NOT be secure. To fix this, please install the ssl module from http://pypi.python.org/pypi/ssl .

I downloaded the package and it contained a setup.py file. I ran:

python setup.py install

and then:

Python was built with Visual Studio 2003; blablabla use MinGW32

Then I installed MinGW32 and now the compilation doesn't work. The end of the compilation errors contains:

ssl/_ssl2.c:1561: error: `CRYPTO_LOCK' undeclared (first use in this function)

error: command 'gcc' failed with exit status 1

What should I do?

Community
  • 1
  • 1
Jader Dias
  • 88,211
  • 155
  • 421
  • 625
  • 1
    I install python in win7x64 and tip no ssl, install setuptools and then pip, last: pip install pyOpenSSL . – BollMose Nov 04 '14 at 08:11
  • @DienBell's comment is what solved it for me (clean install of Windows 8.1, no compiling environment) – WoJ Mar 11 '15 at 14:10
  • see https://stackoverflow.com/questions/45954528/pip-is-configured-with-locations-that-require-tls-ssl-however-the-ssl-module-in – Lawrence Patrick Feb 25 '21 at 06:58

5 Answers5

15

Grab the openssl and libgw32c packages from the gnuwin32 project (download the "Developer files"!) and extract them where you installed gnuwin32 - or if you don't have gnuwin32 tools yet, you can extract it anywhere (e.g. "C:\Program Files\gnuwin32"). Enter the gnuwin32 directory in the "setup.py" file (replace "C:\Utils\GnuWin32" in line 154).

Then you can build the ssl module without problems. I tested it myself, using GCC "4.3.2-tdm-2 mingw32" and with the command line setup.py build -cmingw32 (-cmingw32 forces MinGW as I also have Microsoft's compiler installed). Execute setup.py install after the successful build to install ssl.

AndiDog
  • 68,631
  • 21
  • 159
  • 205
  • 2
    the openssl installer you linked already installed some (or all) of the files present in the libgw32c compressed file. – Jader Dias Feb 14 '10 at 18:57
  • even after I followed your instructions I got the same problem when building the `ssl module – Jader Dias Feb 14 '10 at 18:58
  • 1
    Sorry, I forgot to mention that you need to change setup.py according to your gnuwin32 path. Edited the answer. – AndiDog Feb 14 '10 at 19:02
  • I also had to take help from http://wiki.cython.org/InstallingOnWindows and http://eli.thegreenplace.net/2008/06/28/compiling-python-extensions-with-distutils-and-mingw/ beyond copying the openssl and libgw32c libs in ming32 libs folder – dhaval Nov 25 '10 at 08:48
9

I had to use the following modification of AndiDog's approach:

setup.py build -cmingw32
setup.py install --skip-build

Without the --skip-build option, the install would try to build again and complain about MSVC again:

error: Python was built with Visual Studio 2003;
extensions must be built with a compiler than can generate compatible binaries.
Visual Studio 2003 was not found on this system. If you have Cygwin installed,
you can try compiling with MingW32, by passing "-c mingw32" to setup.py.

Also, initially when using the build command I had a lot of errors like this:

build\temp.win32-2.5\Release\ssl\_ssl2.o:_ssl2.c:(.text+0x1d): undefined reference to `_imp__PyImport_ImportModule'
build\temp.win32-2.5\Release\ssl\_ssl2.o:_ssl2.c:(.text+0x34): undefined reference to `_imp__PyObject_GetAttrString'
build\temp.win32-2.5\Release\ssl\_ssl2.o:_ssl2.c:(.text+0x53): undefined reference to `_imp__PyCObject_AsVoidPtr'

This was because I had originally installed the 64bit version of Python 2.5.4 (python-2.5.4.amd64.msi). I removed that and installed the 32bit version (python-2.5.4.msi). This includes the libpython25.a file which the build command was looking for.

Saxon Druce
  • 17,406
  • 5
  • 50
  • 71
  • When trying to build I'm getting `command gcc failed: No such file or directory`. Any ideas? – Uri May 07 '11 at 11:26
  • 1
    @Uri: Looks like maybe gcc isn't installed, or isn't in the path. If it is, then you might just need to restart your command prompt (the path is only picked up when the command prompt is opened). You can type 'set path' on the command line, to check if the mingw bin directory (eg c:\mingw\bin) is in your path. – Saxon Druce May 07 '11 at 15:43
2

I used AndiDog's and Saxon Druce answers which are 100% correct but might need some clarification for inexperienced users like me:

  1. This is for Windows users only.

  2. Install python 2.5.2 32 bit - it was essential for me as i have x64 system and I first installed python 2.5.2 x64 and the proposed solution did not work for me at all, so 32 bit it is.

  3. Install GCC - http://sourceforge.net/projects/tdm-gcc/files/TDM-GCC%20Installer/Previous/1.1006.0/tdm-gcc-4.5.2.exe/download, I used the latest version, do not forget to select the option add to PATH variable while installing, or you will have to add the path to the GCC bin folder to your environment variable "path" yourself.

  4. Blockquote openssl and libgw32c packages from the gnuwin32 project (download the "Developer files"!) and extract them where you installed gnuwin32 - or if you don't have gnuwin32 tools yet, you can extract it anywhere (e.g. "C:\Program Files\gnuwin32"). Enter the gnuwin32 directory in the "setup.py" of the ssl library file (replace "C:\Utils\GnuWin32" in line 154).

  5. run python setup.py build -cmingw32 (the easiest way is to fire cmd and navigate to the directory where ssl library was extracted to) - this will compile ssl library

  6. run python setup.py install --skip-build to install it

That should do it.

I am actually surprised that they did not manage to add ssl library to app engine sdk or python installer in all this years, may be people do not use it.

DeenSeth
  • 35
  • 5
BanditoBunny
  • 3,658
  • 5
  • 32
  • 40
1

Since TDM-GCC 4.6.1 was released in September 2011. TDM-GCC installer will download the lastest GCC version (4.6.1) even though the tdm-gcc-4.5.2.exe is used. GCC 4.6.1 will cause GCC build error "error: unrecognized command line option '-mno-cygwin'" This is because -mno-cygwin become deprecated in GCC 4.6.1. In order to compile ssl package against python 2.5 we need to use GCC version 4.5.2.

After installing TDM-GCC you need to do extra step from the instruction by @BanditoBunny.

3.1 Download gcc-4.5.2-tdm-1-core.zip from http://sourceforge.net/projects/tdm-gcc/files/TDM-GCC%204.5%20series/4.5.2-tdm-1%20SJLJ/gcc-4.5.2-tdm-1-core.zip/download. Unzip the file into the MinGW32 folder.
3.2 Go to the SSL folder then open a command prompt there. Check GCC version (using gcc --version) to make sure it uses version 4.5.2. Then continue with step 4.

DeenSeth
  • 35
  • 5
1

I've compiled all the instructions at one place to make people's life easy. http://waqasshabbir.tumblr.com/post/18010535789/ssl-module-for-python-2-5-installation-windows-only