【问题标题】:MySQL with Python Flask in Openshift: Internal Server Error在 Openshift 中使用 Python Flask 的 MySQL:内部服务器错误
【发布时间】:2015-02-24 01:13:24
【问题描述】:

第一个奇怪的事情是它在 Openshift 中部署时失败,在我的 localhost 中完美运行。

当我尝试登录用户时出现问题(在 mysql 中查询)。

http://scheduler-sonrie.rhcloud.com/testdb -> 这个测试mysql连接,看起来还可以,

http://scheduler-sonrie.rhcloud.com/signin -> 报告“内部服务器错误”消息失败

这是我的代码https://github.com/rchampa/scheduler-old

部署时出现一些错误:

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

这是我部署应用程序时的全部日志。

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

这是 rhc tail 命令:

==> 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

----------------------------------------

【问题讨论】:

  • 您的 OpenShift 帐户是否启用了 mysql?
  • 是的,它已启用。另外,我添加了新表格。

标签: python mysql flask openshift flask-sqlalchemy


【解决方案1】:

根据您提供的输出,OpenShift 可能安装了 MySQL 核心包,但没有安装 MySQL 开发包,其中包含您的 Python 包所需的库文件。

尝试在您的 OpenShift 环境中从 yum 安装 mysql-devel 软件包1

$ yum install --assumeyes mysql-devel

然后重新安装您的 Python 包(或重新部署,如果它为您执行此操作)。

如果您已成功安装此包(并编译您的 Python 扩展),请考虑将此先决条件添加到您的应用程序的 OpenShift Action Hooks

1--assumeyes 是可选的;它抑制了问题。

【讨论】:

  • 我试过但没有成功,我有新的错误信息:无法在 /var/lib/rpm CRITICAL:yum.main 中打开 Packages 数据库:错误:rpmdb 打开失败
  • @Ricardo 这是一个不相关的问题,但普遍的共识似乎是重建您的 rpm 数据库索引:$ rm -f /var/lib/rpm/__* &amp;&amp; rpm --rebuilddb。如果这是一个新实例,您应该联系 RedHat 支持。 yum 是一个核心包,应该在默认安装中“正常工作”。
  • 感谢您的帮助,但我实际上放弃了,现在我将尝试制作一个业务逻辑较少的简单应用程序(仅限flask+mysql)。
【解决方案2】:

在尝试了几种使事情正常进行的方法后,我找到了实现它的方法。 只需从您的 pip 需求文件中删除行 MySQL-python==1.2.5

我的工作代码可以在https://github.com/rchampa/openshift-template-python-flask-mysql找到

【讨论】:

    猜你喜欢
    • 2014-07-06
    • 1970-01-01
    • 1970-01-01
    • 2021-10-12
    • 2015-11-15
    • 1970-01-01
    • 1970-01-01
    • 2016-11-23
    • 1970-01-01
    相关资源
    最近更新 更多