MySQL with Python Flask in Openshift: Internal Server Error
Question: The first weird thing is that just fails when it's deployed in Openshift, in
my localhost works perfectly.

The issue occurs when I try to login a user(query in mysql).

<http://scheduler-sonrie.rhcloud.com/testdb> -> this test mysql connection and
seems OK,

<http://scheduler-sonrie.rhcloud.com/signin> -> fail reporting a message
"Internal Server Error"

This is my code <https://github.com/rchampa/scheduler-old>

There are a few errors when I deploy:

    
    
    remote:     /usr/bin/ld: cannot find -lmysqlclient
    remote:     collect2: ld returned 1 exit status
    remote:     error: command 'gcc' failed with exit status 1
    remote:     Can't roll back MySQL-python; was not uninstalled
    

And this is the entire logs when I deploy app.

    
    
    remote: Stopping Python 2.7 cartridge
    remote: Syncing git content to other proxy gears
    remote: Building git ref 'master', commit bf9510c
    remote: Activating virtenv
    remote: Checking for pip dependency listed in requirements.txt file..
    remote: Requirement already satisfied (use --upgrade to upgrade): aniso8601==0.92 in /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/dependencies/python/virtenv/lib/python2.7/site-packages (from -r /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/repo/requirements.txt (line 1))
    remote: Requirement already satisfied (use --upgrade to upgrade): Flask==0.10.1 in /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/dependencies/python/virtenv/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg (from -r /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/repo/requirements.txt (line 2))
    remote: Requirement already satisfied (use --upgrade to upgrade): Flask-HTTPAuth==2.3.0 in /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/dependencies/python/virtenv/lib/python2.7/site-packages (from -r /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/repo/requirements.txt (line 3))
    remote: Requirement already satisfied (use --upgrade to upgrade): Flask-RESTful==0.3.1 in /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/dependencies/python/virtenv/lib/python2.7/site-packages (from -r /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/repo/requirements.txt (line 4))
    remote: Requirement already satisfied (use --upgrade to upgrade): Flask-SQLAlchemy==2.0 in /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/dependencies/python/virtenv/lib/python2.7/site-packages (from -r /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/repo/requirements.txt (line 5))
    remote: Requirement already satisfied (use --upgrade to upgrade): Flask-WTF==0.10.3 in /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/dependencies/python/virtenv/lib/python2.7/site-packages (from -r /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/repo/requirements.txt (line 6))
    remote: Requirement already satisfied (use --upgrade to upgrade): itsdangerous==0.24 in /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/dependencies/python/virtenv/lib/python2.7/site-packages/itsdangerous-0.24-py2.7.egg (from -r /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/repo/requirements.txt (line 7))
    remote: Requirement already satisfied (use --upgrade to upgrade): Jinja2==2.7.3 in /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/dependencies/python/virtenv/lib/python2.7/site-packages (from -r /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/repo/requirements.txt (line 8))
    remote: Requirement already satisfied (use --upgrade to upgrade): MarkupSafe==0.23 in /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/dependencies/python/virtenv/lib/python2.7/site-packages (from -r /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/repo/requirements.txt (line 9))
    remote: Downloading/unpacking MySQL-python==1.2.5 (from -r /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/repo/requirements.txt (line 10))
    remote:   Running setup.py egg_info for package MySQL-python
    remote:     
    remote: Requirement already satisfied (use --upgrade to upgrade): pytz==2014.10 in /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/dependencies/python/virtenv/lib/python2.7/site-packages (from -r /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/repo/requirements.txt (line 11))
    remote: Requirement already satisfied (use --upgrade to upgrade): six==1.8.0 in /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/dependencies/python/virtenv/lib/python2.7/site-packages (from -r /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/repo/requirements.txt (line 12))
    remote: Requirement already satisfied (use --upgrade to upgrade): SQLAlchemy==0.9.8 in /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/dependencies/python/virtenv/lib/python2.7/site-packages (from -r /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/repo/requirements.txt (line 13))
    remote: Requirement already satisfied (use --upgrade to upgrade): Werkzeug==0.9.6 in /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/dependencies/python/virtenv/lib/python2.7/site-packages (from -r /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/repo/requirements.txt (line 14))
    remote: Requirement already satisfied (use --upgrade to upgrade): WTForms==2.0.1 in /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/dependencies/python/virtenv/lib/python2.7/site-packages (from -r /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/repo/requirements.txt (line 15))
    remote: Installing collected packages: MySQL-python
    remote:   Found existing installation: MySQL-python 1.2.3
    remote:     Not uninstalling MySQL-python at /opt/rh/python27/root/usr/lib64/python2.7/site-packages, outside environment /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/dependencies/python/virtenv
    remote:   Running setup.py install for MySQL-python
    remote:     building '_mysql' extension
    remote:     gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/opt/rh/mysql55/root/usr/include/mysql -I/opt/rh/python27/root/usr/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC -fPIC -g -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing -DMY_PTHREAD_FASTMUTEX=1
    remote:     In file included from /opt/rh/mysql55/root/usr/include/mysql/my_config.h:14,
    remote:                      from _mysql.c:44:
    remote:     /opt/rh/mysql55/root/usr/include/mysql/my_config_x86_64.h:422:1: warning: "HAVE_WCSCOLL" redefined
    remote:     In file included from /opt/rh/python27/root/usr/include/python2.7/pyconfig.h:6,
    remote:                      from /opt/rh/python27/root/usr/include/python2.7/Python.h:8,
    remote:                      from _mysql.c:29:
    remote:     /opt/rh/python27/root/usr/include/python2.7/pyconfig-64.h:908:1: warning: this is the location of the previous definition
    remote:     gcc -pthread -shared -L/usr/lib6464 build/temp.linux-x86_64-2.7/_mysql.o -L/opt/rh/mysql55/root/usr/lib64/mysql -L/opt/rh/python27/root/usr/lib64 -lmysqlclient -lpthread -lz -lm -lrt -lssl -lcrypto -ldl -lpython2.7 -o build/lib.linux-x86_64-2.7/_mysql.so
    remote:     /usr/bin/ld: cannot find -lmysqlclient
    remote:     collect2: ld returned 1 exit status
    remote:     error: command 'gcc' failed with exit status 1
    remote:     Complete output from command /var/lib/openshift/549c86454382ecb3c400010c/python/virtenv/bin/python2.7 -c "import setuptools;__file__='/var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/dependencies/python/virtenv/build/MySQL-python/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-PDPMLU-record/install-record.txt --single-version-externally-managed --install-headers /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/dependencies/python/virtenv/include/site/python2.7:
    remote:     running install
    remote: 
    remote: running build
    remote: 
    remote: running build_py
    remote: 
    remote: creating build
    remote: 
    remote: creating build/lib.linux-x86_64-2.7
    remote: 
    remote: copying _mysql_exceptions.py -> build/lib.linux-x86_64-2.7
    remote: 
    remote: creating build/lib.linux-x86_64-2.7/MySQLdb
    remote: 
    remote: copying MySQLdb/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb
    remote: 
    remote: copying MySQLdb/converters.py -> build/lib.linux-x86_64-2.7/MySQLdb
    remote: 
    remote: copying MySQLdb/connections.py -> build/lib.linux-x86_64-2.7/MySQLdb
    remote: 
    remote: copying MySQLdb/cursors.py -> build/lib.linux-x86_64-2.7/MySQLdb
    remote: 
    remote: copying MySQLdb/release.py -> build/lib.linux-x86_64-2.7/MySQLdb
    remote: 
    remote: copying MySQLdb/times.py -> build/lib.linux-x86_64-2.7/MySQLdb
    remote: 
    remote: creating build/lib.linux-x86_64-2.7/MySQLdb/constants
    remote: 
    remote: copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
    remote: 
    remote: copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
    remote: 
    remote: copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
    remote: 
    remote: copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
    remote: 
    remote: copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
    remote: 
    remote: copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
    remote: 
    remote: copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-2.7/MySQLdb/constants
    remote: 
    remote: running build_ext
    remote: 
    remote: building '_mysql' extension
    remote: 
    remote: creating build/temp.linux-x86_64-2.7
    remote: 
    remote: gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/opt/rh/mysql55/root/usr/include/mysql -I/opt/rh/python27/root/usr/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC -fPIC -g -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing -DMY_PTHREAD_FASTMUTEX=1
    remote: 
    remote: In file included from /opt/rh/mysql55/root/usr/include/mysql/my_config.h:14,
    remote: 
    remote:                  from _mysql.c:44:
    remote: 
    remote: /opt/rh/mysql55/root/usr/include/mysql/my_config_x86_64.h:422:1: warning: "HAVE_WCSCOLL" redefined
    remote: 
    remote: In file included from /opt/rh/python27/root/usr/include/python2.7/pyconfig.h:6,
    remote: 
    remote:                  from /opt/rh/python27/root/usr/include/python2.7/Python.h:8,
    remote: 
    remote:                  from _mysql.c:29:
    remote: 
    remote: /opt/rh/python27/root/usr/include/python2.7/pyconfig-64.h:908:1: warning: this is the location of the previous definition
    remote: 
    remote: gcc -pthread -shared -L/usr/lib6464 build/temp.linux-x86_64-2.7/_mysql.o -L/opt/rh/mysql55/root/usr/lib64/mysql -L/opt/rh/python27/root/usr/lib64 -lmysqlclient -lpthread -lz -lm -lrt -lssl -lcrypto -ldl -lpython2.7 -o build/lib.linux-x86_64-2.7/_mysql.so
    remote: 
    remote: /usr/bin/ld: cannot find -lmysqlclient
    remote: 
    remote: collect2: ld returned 1 exit status
    remote: 
    remote: error: command 'gcc' failed with exit status 1
    remote: 
    remote: ----------------------------------------
    remote:   Can't roll back MySQL-python; was not uninstalled
    remote: Cleaning up...
    remote: Command /var/lib/openshift/549c86454382ecb3c400010c/python/virtenv/bin/python2.7 -c "import setuptools;__file__='/var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/dependencies/python/virtenv/build/MySQL-python/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-PDPMLU-record/install-record.txt --single-version-externally-managed --install-headers /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/dependencies/python/virtenv/include/site/python2.7 failed with error code 1 in /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/dependencies/python/virtenv/build/MySQL-python
    remote: Traceback (most recent call last):
    remote:   File "/var/lib/openshift/549c86454382ecb3c400010c/python/virtenv/bin/pip", line 12, in <module>
    remote:     load_entry_point('pip==1.4', 'console_scripts', 'pip')()
    remote:   File "/var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/dependencies/python/virtenv/lib/python2.7/site-packages/pip/__init__.py", line 147, in main
    remote:     return command.main(args[1:], options)
    remote:   File "/var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/dependencies/python/virtenv/lib/python2.7/site-packages/pip/basecommand.py", line 171, in main
    remote:     log_fp = open_logfile(log_fn, 'w')
    remote:   File "/var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/dependencies/python/virtenv/lib/python2.7/site-packages/pip/basecommand.py", line 200, in open_logfile
    remote:     os.makedirs(dirname)
    remote:   File "/var/lib/openshift/549c86454382ecb3c400010c/python/virtenv/lib64/python2.7/os.py", line 157, in makedirs
    remote:     mkdir(name, mode)
    remote: OSError: [Errno 13] Permission denied: '/var/lib/openshift/549c86454382ecb3c400010c/.pip'
    remote: Running setup.py script..
    remote: running develop
    remote: running egg_info
    remote: creating FlaskApp.egg-info
    remote: writing requirements to FlaskApp.egg-info/requires.txt
    remote: writing FlaskApp.egg-info/PKG-INFO
    remote: writing top-level names to FlaskApp.egg-info/top_level.txt
    remote: writing dependency_links to FlaskApp.egg-info/dependency_links.txt
    remote: writing manifest file 'FlaskApp.egg-info/SOURCES.txt'
    remote: reading manifest file 'FlaskApp.egg-info/SOURCES.txt'
    remote: writing manifest file 'FlaskApp.egg-info/SOURCES.txt'
    remote: running build_ext
    remote: Creating /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/dependencies/python/virtenv/lib/python2.7/site-packages/FlaskApp.egg-link (link to .)
    remote: FlaskApp 1.0 is already the active version in easy-install.pth
    remote: 
    remote: Installed /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/repo
    remote: Processing dependencies for FlaskApp==1.0
    remote: Searching for Flask==0.10.1
    remote: Best match: Flask 0.10.1
    remote: Processing Flask-0.10.1-py2.7.egg
    remote: Flask 0.10.1 is already the active version in easy-install.pth
    remote: 
    remote: Using /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/dependencies/python/virtenv/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg
    remote: Searching for itsdangerous==0.24
    remote: Best match: itsdangerous 0.24
    remote: Processing itsdangerous-0.24-py2.7.egg
    remote: itsdangerous 0.24 is already the active version in easy-install.pth
    remote: 
    remote: Using /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/dependencies/python/virtenv/lib/python2.7/site-packages/itsdangerous-0.24-py2.7.egg
    remote: Searching for Jinja2==2.7.3
    remote: Best match: Jinja2 2.7.3
    remote: Adding Jinja2 2.7.3 to easy-install.pth file
    remote: 
    remote: Using /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/dependencies/python/virtenv/lib/python2.7/site-packages
    remote: Searching for Werkzeug==0.9.6
    remote: Best match: Werkzeug 0.9.6
    remote: Adding Werkzeug 0.9.6 to easy-install.pth file
    remote: 
    remote: Using /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/dependencies/python/virtenv/lib/python2.7/site-packages
    remote: Searching for MarkupSafe==0.23
    remote: Best match: MarkupSafe 0.23
    remote: Adding MarkupSafe 0.23 to easy-install.pth file
    remote: 
    remote: Using /var/lib/openshift/549c86454382ecb3c400010c/app-root/runtime/dependencies/python/virtenv/lib/python2.7/site-packages
    remote: Finished processing dependencies for FlaskApp==1.0
    remote: Script /var/lib/openshift/549c86454382ecb3c400010c/python//virtenv/bin/activate.fish cannot be made relative (it's not a normal script that starts with #!/var/lib/openshift/549c86454382ecb3c400010c/python/virtenv/bin/python)
    remote: Script /var/lib/openshift/549c86454382ecb3c400010c/python//virtenv/bin/activate.csh cannot be made relative (it's not a normal script that starts with #!/var/lib/openshift/549c86454382ecb3c400010c/python/virtenv/bin/python)
    remote: Preparing build for deployment
    remote: Deployment id is 0aeb5dd6
    remote: Activating deployment
    remote: HAProxy already running
    remote: HAProxy instance is started
    remote: Script /var/lib/openshift/549c86454382ecb3c400010c/python//virtenv/bin/activate.fish cannot be made relative (it's not a normal script that starts with #!/var/lib/openshift/549c86454382ecb3c400010c/python/virtenv/bin/python)
    remote: Script /var/lib/openshift/549c86454382ecb3c400010c/python//virtenv/bin/activate.csh cannot be made relative (it's not a normal script that starts with #!/var/lib/openshift/549c86454382ecb3c400010c/python/virtenv/bin/python)
    remote: Starting Python 2.7 cartridge (app.py server)
    remote: -------------------------
    remote: Git Post-Receive Result: success
    remote: Activation status: success
    remote: Deployment completed with status: success
    

And this is the rhc tail command:

    
    
    ==> app-root/logs/python.log-20141226024118 <==
      File "/opt/rh/python27/root/usr/lib64/python2.7/socket.py", line 303, in flush
        self._sock.sendall(view[write_offset:write_offset+buffer_size])
    error: [Errno 32] Broken pipe
    ----------------------------------------
    127.13.64.129 - - [26/Dec/2014 02:41:18] "GET / HTTP/1.0" 200 -
    ----------------------------------------
    Exception happened during processing of request from ('127.13.64.129', 20268)
    Traceback (most recent call last):
      File "/opt/rh/python27/root/usr/lib64/python2.7/SocketServer.py", line 295, in _handle_request_noblock
        self.process_request(request, client_address)
    
    ==> app-root/logs/python.log-20141226073626 <==
    127.13.64.129 - - [26/Dec/2014 07:36:26] "GET / HTTP/1.0" 200 -
    ----------------------------------------
    Exception happened during processing of request from ('127.13.64.129', 29632)
    Traceback (most recent call last):
      File "/opt/rh/python27/root/usr/lib64/python2.7/SocketServer.py", line 295, in _handle_request_noblock
        self.process_request(request, client_address)
      File "/opt/rh/python27/root/usr/lib64/python2.7/SocketServer.py", line 321, in process_request
        self.finish_request(request, client_address)
      File "/opt/rh/python27/root/usr/lib64/python2.7/SocketServer.py", line 334, in finish_request
        self.RequestHandlerClass(request, client_address, self)
    
    ==> app-root/logs/python.log-20141225094557 <==
        self._sock.sendall(view[write_offset:write_offset+buffer_size])
    error: [Errno 32] Broken pipe
    ----------------------------------------
    127.13.64.129 - - [25/Dec/2014 21:45:57] "GET / HTTP/1.0" 200 -
    ----------------------------------------
    Exception happened during processing of request from ('127.13.64.129', 22441)
    Traceback (most recent call last):
      File "/opt/rh/python27/root/usr/lib64/python2.7/SocketServer.py", line 295, in _handle_request_noblock
        self.process_request(request, client_address)
      File "/opt/rh/python27/root/usr/lib64/python2.7/SocketServer.py", line 321, in process_request
    
    ==> app-root/logs/haproxy.log <==
    [WARNING] 359/153915 (493821) : Server express/local-gear is UP (leaving maintenance).
    [WARNING] 359/154912 (46051) : config : log format ignored for proxy 'stats' since it has no log address.
    [WARNING] 359/154912 (46051) : config : log format ignored for proxy 'express' since it has no log address.
    [WARNING] 359/154912 (493821) : Stopping proxy stats in 0 ms.
    [WARNING] 359/154912 (493821) : Stopping proxy express in 0 ms.
    [WARNING] 359/154912 (493821) : Proxy stats stopped (FE: 4 conns, BE: 0 conns).
    [WARNING] 359/154912 (493821) : Proxy express stopped (FE: 28 conns, BE: 28 conns).
    [WARNING] 359/155417 (46051) : Server express/local-gear is DOWN for maintenance.
    [ALERT] 359/155417 (46051) : proxy 'express' has no server available!
    [WARNING] 359/155445 (46051) : Server express/local-gear is UP (leaving maintenance).
    
    ==> app-root/logs/haproxy_ctld.log <==
    I, [2014-12-25T16:52:03.544221 #363070]  INFO -- : Starting haproxy_ctld
    I, [2014-12-26T14:54:21.950056 #454284]  INFO -- : Starting haproxy_ctld
    I, [2014-12-26T15:05:45.382845 #476536]  INFO -- : Starting haproxy_ctld
    I, [2014-12-26T15:12:54.659244 #493843]  INFO -- : Starting haproxy_ctld
    
    ==> app-root/logs/python.log-20141226123259 <==
    Exception happened during processing of request from ('127.13.64.129', 22475)
    Traceback (most recent call last):
      File "/opt/rh/python27/root/usr/lib64/python2.7/SocketServer.py", line 295, in _handle_request_noblock
        self.process_request(request, client_address)
      File "/opt/rh/python27/root/usr/lib64/python2.7/SocketServer.py", line 321, in process_request
        self.finish_request(request, client_address)
      File "/opt/rh/python27/root/usr/lib64/python2.7/SocketServer.py", line 334, in finish_request
        self.RequestHandlerClass(request, client_address, self)
      File "/opt/rh/python27/root/usr/lib64/python2.7/SocketServer.py", line 651, in __init__
        self.finish()
    
    ==> app-root/logs/python.log <==
      File "/opt/rh/python27/root/usr/lib64/python2.7/SocketServer.py", line 651, in __init__
        self.finish()
      File "/opt/rh/python27/root/usr/lib64/python2.7/SocketServer.py", line 710, in finish
        self.wfile.close()
      File "/opt/rh/python27/root/usr/lib64/python2.7/socket.py", line 279, in close
        self.flush()
      File "/opt/rh/python27/root/usr/lib64/python2.7/socket.py", line 303, in flush
        self._sock.sendall(view[write_offset:write_offset+buffer_size])
    error: [Errno 32] Broken pipe
    ----------------------------------------
    127.13.64.129 - - [26/Dec/2014 16:02:20] "GET / HTTP/1.0" 200 -
    ----------------------------------------
    Exception happened during processing of request from ('127.13.64.129', 22815)
    Traceback (most recent call last):
      File "/opt/rh/python27/root/usr/lib64/python2.7/SocketServer.py", line 295, in _handle_request_noblock
        self.process_request(request, client_address)
      File "/opt/rh/python27/root/usr/lib64/python2.7/SocketServer.py", line 321, in process_request
        self.finish_request(request, client_address)
      File "/opt/rh/python27/root/usr/lib64/python2.7/SocketServer.py", line 334, in finish_request
        self.RequestHandlerClass(request, client_address, self)
      File "/opt/rh/python27/root/usr/lib64/python2.7/SocketServer.py", line 651, in __init__
        self.finish()
      File "/opt/rh/python27/root/usr/lib64/python2.7/SocketServer.py", line 710, in finish
        self.wfile.close()
      File "/opt/rh/python27/root/usr/lib64/python2.7/socket.py", line 279, in close
        self.flush()
      File "/opt/rh/python27/root/usr/lib64/python2.7/socket.py", line 303, in flush
        self._sock.sendall(view[write_offset:write_offset+buffer_size])
    error: [Errno 32] Broken pipe
    ----------------------------------------
    127.13.64.129 - - [26/Dec/2014 16:02:22] "GET / HTTP/1.0" 200 -
    ----------------------------------------
    Exception happened during processing of request from ('127.13.64.129', 22818)
    Traceback (most recent call last):
      File "/opt/rh/python27/root/usr/lib64/python2.7/SocketServer.py", line 295, in _handle_request_noblock
        self.process_request(request, client_address)
      File "/opt/rh/python27/root/usr/lib64/python2.7/SocketServer.py", line 321, in process_request
        self.finish_request(request, client_address)
      File "/opt/rh/python27/root/usr/lib64/python2.7/SocketServer.py", line 334, in finish_request
        self.RequestHandlerClass(request, client_address, self)
      File "/opt/rh/python27/root/usr/lib64/python2.7/SocketServer.py", line 651, in __init__
        self.finish()
      File "/opt/rh/python27/root/usr/lib64/python2.7/SocketServer.py", line 710, in finish
        self.wfile.close()
      File "/opt/rh/python27/root/usr/lib64/python2.7/socket.py", line 279, in close
        self.flush()
      File "/opt/rh/python27/root/usr/lib64/python2.7/socket.py", line 303, in flush
        self._sock.sendall(view[write_offset:write_offset+buffer_size])
    error: [Errno 32] Broken pipe
    ----------------------------------------
    127.13.64.129 - - [26/Dec/2014 16:02:24] "GET / HTTP/1.0" 200 -
    ----------------------------------------
    Exception happened during processing of request from ('127.13.64.129', 22829)
    Traceback (most recent call last):
      File "/opt/rh/python27/root/usr/lib64/python2.7/SocketServer.py", line 295, in _handle_request_noblock
        self.process_request(request, client_address)
      File "/opt/rh/python27/root/usr/lib64/python2.7/SocketServer.py", line 321, in process_request
        self.finish_request(request, client_address)
      File "/opt/rh/python27/root/usr/lib64/python2.7/SocketServer.py", line 334, in finish_request
        self.RequestHandlerClass(request, client_address, self)
      File "/opt/rh/python27/root/usr/lib64/python2.7/SocketServer.py", line 651, in __init__
        self.finish()
      File "/opt/rh/python27/root/usr/lib64/python2.7/SocketServer.py", line 710, in finish
        self.wfile.close()
      File "/opt/rh/python27/root/usr/lib64/python2.7/socket.py", line 279, in close
        self.flush()
      File "/opt/rh/python27/root/usr/lib64/python2.7/socket.py", line 303, in flush
        self._sock.sendall(view[write_offset:write_offset+buffer_size])
    error: [Errno 32] Broken pipe
    
    ----------------------------------------
    


Answer: Based on the output you provided, OpenShift likely installed the MySQL core
package but didn't install the MySQL development package, which includes the
library files your Python package needs.

Try installing the `mysql-devel` package from `yum` in your OpenShift
environment1:

    
    
    $ yum install --assumeyes mysql-devel
    

Then reinstall your Python packages (or redeploy, if it does this for you).

If you have success with installing this package (and compiling your Python
extension), consider adding this prerequisite to your application's [OpenShift
Action Hooks](https://developers.openshift.com/en/managing-action-hooks.html).

1 `--assumeyes` is optional; it suppresses questions.

