gpt4 book ai didi

python - Worker进程运行时异常 "heroku local"

转载 作者:可可西里 更新时间:2023-11-01 07:44:06 28 4
gpt4 key购买 nike

我最近获得了一个正在使用 heroku 构建的项目。我想在本地运行它但是我遇到了麻烦而且我对 Heroku 没有太多经验。这是我尝试在本地运行 heroku 时得到的结果。

Mac 终端命令

kaMacintosh:zddev ka$ heroku local
forego | starting web.1 on port 5000
web.1 | [2015-12-26 15:12:43 -0500] [1741] [INFO] Starting gunicorn 19.4.1
web.1 | [2015-12-26 15:12:43 -0500] [1741] [INFO] Listening at: http://0.0.0.0:5000 (1741)
web.1 | [2015-12-26 15:12:43 -0500] [1741] [INFO] Using worker: sync
web.1 | [2015-12-26 15:12:43 -0500] [1744] [INFO] Booting worker with pid: 1744
web.1 | [2015-12-26 15:12:43 -0500] [1744] [ERROR] Exception in worker process:
web.1 | zd/main.py", line 6, in <module>
web.1 | ka/Documents/zdenvs/zddev/main.py", line 6, in <module>
web.1 | [2015-12-26 15:12:43 -0500] [1744] [INFO] Worker exiting (pid: 1744)
web.1 | Traceback (most recent call last):
web.1 | sys.exit(run())
web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 74, in run
web.1 | super(Application, self).run()
web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 72, in run
web.1 | Arbiter(self).run()
web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 179, in run
web.1 | self.manage_workers()
web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 482, in manage_workers
web.1 | self.spawn_workers()
web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 549, in spawn_workers
web.1 | time.sleep(0.1 * random.random())
web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 219, in handle_chld
web.1 | self.reap_workers()
web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 464, in reap_workers
web.1 | raise HaltServer(reason, self.WORKER_BOOT_ERROR)
web.1 | gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>

简介

web: gunicorn main:app --log-file=-

第 6 行似乎是 mysql.connector 的问题,这里是 main.py 的前几行

主要.py

import os
import sys
import json
import urllib
import custom
import mysql.connector
import datetime
import operator

from flask import Flask, jsonify
from flask import render_template
from flask import request, redirect, url_for
from mysql.connector import errorcode
application = Flask(__name__)
app = application

有关导致错误的原因或解决方法的任何想法。是不是真的是 mysql.connector 导致了 main.py 中第 6 行的问题?我正在使用 Python 2.7.11。

在自己的产品上运行 gunicorn main:app

Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 515, in spawn_worker
worker.init_process()
File "/usr/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 122, in init_process
self.load_wsgi()
File "/usr/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 130, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
return self.load_wsgiapp()
File "/usr/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/local/lib/python2.7/site-packages/gunicorn/util.py", line 354, in import_app
__import__(module)
File "/Users/ka/Documents/zdenvs/zddev/main.py", line 6, in <module>
import mysql.connector
ImportError: No module named mysql.connector
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 515, in spawn_worker
worker.init_process()
File "/usr/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 122, in init_process
self.load_wsgi()
File "/usr/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 130, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
return self.load_wsgiapp()
File "/usr/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/local/lib/python2.7/site-packages/gunicorn/util.py", line 354, in import_app
__import__(module)
File "/Users/ka/Documents/zdenvs/zddev/main.py", line 6, in <module>
import mysql.connector
ImportError: No module named mysql.connector
[2016-01-04 15:34:18 -0500] [6225] [INFO] Worker exiting (pid: 6225)
Traceback (most recent call last):
File "/usr/local/bin/gunicorn", line 11, in <module>
sys.exit(run())
File "/usr/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 74, in run
WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
File "/usr/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 192, in run
super(Application, self).run()
File "/usr/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 72, in run
Arbiter(self).run()
File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 179, in run
self.manage_workers()
File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 482, in manage_workers
self.spawn_workers()
File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 549, in spawn_workers
time.sleep(0.1 * random.random())
File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 219, in handle_chld
self.reap_workers()
File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 464, in reap_workers
raise HaltServer(reason, self.WORKER_BOOT_ERROR)
gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>

最佳答案

mysql-connector-python 库存在问题。它在我的项目中途被放弃了,所以它安装在 heroku 实例上但没有安装在我的本地机器上。相反,我只是替换了 requirements.txt 文件中的这一行:

mysql-connector-python==2.0.4

https://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.0.4.tar.gz

关于python - Worker进程运行时异常 "heroku local",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34474947/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com