1

I'm using gdal in a python script that runs flask (on apache + mod_wsgi). When starting the server i get this error:

ImportError: /usr/bin/anaconda/lib/python2.7/site-packages/osgeo/../../.././libcurl.so.4: undefined symbol: SSLv2_client_method

the error generates when importing gdal on:

from osgeo import gdal

the thing is that, when running that command (importing gdal) from the console of the same python interpreter, it works ok... but it won't work when running the same script as a WSGI daemon.

my wsgi file is as follows:

<VirtualHost *:80>
    ServerName ____________

    WSGIDaemonProcess aurapi user=avt group=avt threads=5 python-path=/usr/bin/anaconda/lib/python2.7/site-packages python-home=/usr/bin/anaconda/bin
    WSGIScriptAlias / /var/api/aurapi/aurapi.wsgi

    <Directory /var/api/aurapi>
            WSGIProcessGroup aurapi
            WSGIApplicationGroup %{GLOBAL}
            WSGIScriptReloading On
            Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

this happens only with gdal, all other libraries work great.

thanks in advance!

luckyshonway
  • 101
  • 1
  • 7

1 Answers1

1

The reason is that you are using Anaconda Python and also have mod_ssl module enabled in Apache.

This causes a problem because Anaconda Python ignores the system OpenSSL libraries and bundles its own libraries. The mod_ssl module when loaded into Apache will use the system OpenSSL libraries though and so they get loaded first. When anything in Python tries to use SSL module from Anaconda Python, the OS sees that system OpenSSL library is already loaded (via mod_ssl), and so the Anaconda OpenSSL library doesn't get used. Because the OpenSSL library in Anaconda Python is a different version or incompatible in some other way, then all sorts of strange problems will occur as any Python modules will be compiled expecting the Anaconda version of the OpenSSL library.

In short, the bundling of OpenSSL by Anaconda Python, and also Python 3.6 from the PSF on MacOS X, means that when using either of those with mod_wsgi, you cannot use mod_ssl with Apache, otherwise you will encounter problems.

Graham Dumpleton
  • 57,726
  • 6
  • 119
  • 134
  • thanks a lot for your answer! this means that, as i'll be disabling mod_ssl, I wont be able to use https for this application? it's a really bad tradeoff!! – luckyshonway Jul 13 '17 at 06:11
  • That is the problem that Anaconda has caused. Use system Python packages if you really don't have a need for Anaconda Python. – Graham Dumpleton Jul 13 '17 at 07:07
  • ditched anaconda and switched to the distro's python and it works... thanks for the help! It would have been interesting to find if miniconda does the same, but didn't have the time to try it. – luckyshonway Jul 13 '17 at 21:48