【问题标题】:Getting a "no module named flask" error when deploying to Heroku?部署到 Heroku 时出现“没有名为 flask 的模块”错误?
【发布时间】:2015-04-21 16:39:24
【问题描述】:

我无法将我的应用程序部署到 heroku。我正在从根目录中名为 app.py 的文件启动服务器,并将 Flask 安装在名为 flask 的文件夹中的 venv 中,我得到的错误是“没有名为 flask 的模块”

heroku 日志如下:

2015-04-21T09:18:36.128263+00:00 app[web.1]: Traceback (most recent call last):
    2015-04-21T09:18:36.135666+00:00 app[web.1]: ImportError: No module named flask
    2015-04-21T09:18:36.135349+00:00 app[web.1]:     from flask import Flask, url_for
    2015-04-21T09:18:37.102956+00:00 heroku[web.1]: State changed from starting to crashed
    2015-04-21T09:18:37.072990+00:00 heroku[web.1]: Process exited with status 1
    2015-04-21T10:03:46.376428+00:00 heroku[web.1]: State changed from crashed to starting
    2015-04-21T10:03:48.581259+00:00 heroku[web.1]: Starting process with command `python app.py --log-file=-`
    2015-04-21T10:03:50.464852+00:00 app[web.1]:   File "app.py", line 2, in <module>
    2015-04-21T10:03:50.464953+00:00 app[web.1]:     from flask import Flask, url_for
    2015-04-21T10:03:50.465130+00:00 app[web.1]: ImportError: No module named flask

我的 app.py 是:

#!flask/bin/python
import os
from flask import Flask, url_for
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.script import Manager
from flask.ext.restless import APIManager
from flask.ext.assets import Environment, Bundle
from sqlalchemy.dialects.postgresql import ARRAY
from marshmallow import Schema
from marshmallow import fields
import flask 
import json

flashcards = Flask(__name__)

flashcards.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://localhost/flashcards'
db = SQLAlchemy(flashcards)


class User(db.Model):
    __tablename__ = 'users'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64), unique=True)
    decks = db.relationship('Deck', backref='users')

class Deck(db.Model):
    __tablename__ = 'decks'
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(64), unique=True)
    cards = db.relationship('Card', backref='deck')
    user_id = db.Column(db.Integer, db.ForeignKey('users.id'), index=True)
    last_session = db.Column(db.BigInteger) 
    session_num = db.Column(db.Integer, default=1)

class Card(db.Model):
    __tablename__ = 'cards'
    id = db.Column(db.Integer, primary_key=True)
    question = db.Column(db.String, unique=True)
    answer = db.Column(db.Text)
    deck_id = db.Column(db.Integer, db.ForeignKey('decks.id'), index=True)
    box_id = db.Column(db.Integer, default=0) 

db.create_all()

manager = flask.ext.restless.APIManager(flashcards, flask_sqlalchemy_db=db)


manager.create_api(User, methods=['GET', 'POST', 'PUT', 'DELETE'])
manager.create_api(Deck, methods=['GET', 'POST', 'PUT','DELETE'])
manager.create_api(Card, methods=['GET', 'POST', 'PUT','DELETE'])


@flashcards.route('/')
def root():
    return flashcards.send_static_file('index.html')

if __name__ == '__main__':
    port = int(os.environ.get('PORT', 5000))
    flashcards.run(host='0.0.0.0', port=port)

编辑:

requirements.txt

alembic==0.7.5.post2
aniso8601==0.92
Flask==0.10.1
Flask-Assets==0.10
Flask-Migrate==1.3.1
Flask-RESTful==0.3.2
Flask-Restless==0.17.0
Flask-Script==2.0.5
Flask-SQLAlchemy==2.0
gunicorn==19.3.0
itsdangerous==0.24
Jinja2==2.7.3
Mako==1.0.1
MarkupSafe==0.23
marshmallow==1.2.4
mimerender==0.5.5
psycopg2==2.6
python-dateutil==2.4.2
python-mimeparse==0.1.4
pytz==2015.2
six==1.9.0
SQLAlchemy==0.9.9
webassets==0.10.1
Werkzeug==0.10.4

Heroku 构建输出

    remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Deleting 4 files matching .slugignore patterns.
remote: -----> Removing .DS_Store files
remote: -----> Python app detected
remote: -----> Installing runtime (python-2.7.9)
remote: -----> Installing dependencies with pip
remote:        Collecting alembic==0.7.5.post2 (from -r requirements.txt (line 1))
remote:          Downloading alembic-0.7.5.post2.tar.gz (616kB)
remote:        Collecting aniso8601==0.92 (from -r requirements.txt (line 2))
remote:          Downloading aniso8601-0.92.tar.gz
remote:        Collecting Flask==0.10.1 (from -r requirements.txt (line 3))
remote:          Downloading Flask-0.10.1.tar.gz (544kB)
remote:        Collecting Flask-Assets==0.10 (from -r requirements.txt (line 4))
remote:          Downloading Flask-Assets-0.10.tar.gz
remote:        Collecting Flask-Migrate==1.3.1 (from -r requirements.txt (line 5))
remote:          Downloading Flask-Migrate-1.3.1.tar.gz
remote:        Collecting Flask-RESTful==0.3.2 (from -r requirements.txt (line 6))
remote:          Downloading Flask_RESTful-0.3.2-py2.py3-none-any.whl
remote:        Collecting Flask-Restless==0.17.0 (from -r requirements.txt (line 7))
remote:          Downloading Flask-Restless-0.17.0.tar.gz (42kB)
remote:        Collecting Flask-Script==2.0.5 (from -r requirements.txt (line 8))
remote:          Downloading Flask-Script-2.0.5.tar.gz (42kB)
remote:        Collecting Flask-SQLAlchemy==2.0 (from -r requirements.txt (line 9))
remote:          Downloading Flask-SQLAlchemy-2.0.tar.gz (93kB)
remote:        Collecting gunicorn==19.3.0 (from -r requirements.txt (line 10))
remote:          Downloading gunicorn-19.3.0-py2.py3-none-any.whl (110kB)
remote:        Collecting itsdangerous==0.24 (from -r requirements.txt (line 11))
remote:          Downloading itsdangerous-0.24.tar.gz (46kB)
remote:        Collecting Jinja2==2.7.3 (from -r requirements.txt (line 12))
remote:          Downloading Jinja2-2.7.3.tar.gz (378kB)
remote:        Collecting Mako==1.0.1 (from -r requirements.txt (line 13))
remote:          Downloading Mako-1.0.1.tar.gz (473kB)
remote:        Collecting MarkupSafe==0.23 (from -r requirements.txt (line 14))
remote:          Downloading MarkupSafe-0.23.tar.gz
remote:        Collecting marshmallow==1.2.4 (from -r requirements.txt (line 15))
remote:          Downloading marshmallow-1.2.4-py2.py3-none-any.whl (42kB)
remote:        Collecting mimerender==0.5.5 (from -r requirements.txt (line 16))
remote:          Downloading mimerender-0.5.5.tar.gz
remote:        Collecting psycopg2==2.6 (from -r requirements.txt (line 17))
remote:          Downloading psycopg2-2.6.tar.gz (367kB)
remote:        Collecting python-dateutil==2.4.2 (from -r requirements.txt (line 18))
remote:          Downloading python_dateutil-2.4.2-py2.py3-none-any.whl (188kB)
remote:        Collecting python-mimeparse==0.1.4 (from -r requirements.txt (line 19))
remote:          Downloading python-mimeparse-0.1.4.tar.gz
remote:        Collecting pytz==2015.2 (from -r requirements.txt (line 20))
remote:          Downloading pytz-2015.2-py2.py3-none-any.whl (476kB)
remote:        Collecting six==1.9.0 (from -r requirements.txt (line 21))
remote:          Downloading six-1.9.0-py2.py3-none-any.whl
remote:        Collecting SQLAlchemy==0.9.9 (from -r requirements.txt (line 22))
remote:          Downloading SQLAlchemy-0.9.9.tar.gz (4.2MB)
remote:        Collecting webassets==0.10.1 (from -r requirements.txt (line 23))
remote:          Downloading webassets-0.10.1.tar.gz (167kB)
remote:        Collecting Werkzeug==0.10.4 (from -r requirements.txt (line 24))
remote:          Downloading Werkzeug-0.10.4-py2.py3-none-any.whl (293kB)
remote:        Installing collected packages: Werkzeug, webassets, SQLAlchemy, six, pytz, python-mimeparse, python-dateutil, psycopg2, mimerender, marshmallow, MarkupSafe, Mako, Jinja2, itsdangerous, gunicorn, Flask-SQLAlchemy, Flask-Script, Flask-Restless, Flask-RESTful, Flask-Migrate, Flask-Assets, Flask, aniso8601, alembic
remote:        
remote:          Running setup.py install for webassets
remote:            Installing webassets script to /app/.heroku/python/bin
remote:          Running setup.py install for SQLAlchemy
remote:            building 'sqlalchemy.cprocessors' extension
remote:            gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/app/.heroku/python/include/python2.7 -c lib/sqlalchemy/cextension/processors.c -o build/temp.linux-x86_64-2.7/lib/sqlalchemy/cextension/processors.o
remote:            gcc -pthread -shared build/temp.linux-x86_64-2.7/lib/sqlalchemy/cextension/processors.o -o build/lib.linux-x86_64-2.7/sqlalchemy/cprocessors.s
remote:            building 'sqlalchemy.cresultproxy' extension
remote:            gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/app/.heroku/python/include/python2.7 -c lib/sqlalchemy/cextension/resultproxy.c -o build/temp.linux-x86_64-2.7/lib/sqlalchemy/cextension/resultproxy.o
remote:            gcc -pthread -shared build/temp.linux-x86_64-2.7/lib/sqlalchemy/cextension/resultproxy.o -o build/lib.linux-x86_64-2.7/sqlalchemy/cresultproxy.so
remote:            building 'sqlalchemy.cutils' extension
remote:            gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/app/.heroku/python/include/python2.7 -c lib/sqlalchemy/cextension/utils.c -o build/temp.linux-x86_64-2.7/lib/sqlalchemy/cextension/utils.o
remote:            gcc -pthread -shared build/temp.linux-x86_64-2.7/lib/sqlalchemy/cextension/utils.o -o build/lib.linux-x86_64-2.7/sqlalchemy/cutils.so
remote:        
remote:        
remote:          Running setup.py install for python-mimeparse
remote:        
remote:          Running setup.py install for psycopg2
remote:            building 'psycopg2._psycopg' extension
remote:            gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090306 -DHAVE_LO64=1 -I/app/.heroku/python/include/python2.7 -I. -I/usr/include/postgresql -I/usr/include/postgresql/9.3/server -c psycopg/psycopgmodule.c -o build/temp.linux-x86_64-2.7/psycopg/psycopgmodule.o -Wdeclaration-after-statement
remote:            gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090306 -DHAVE_LO64=1 -I/app/.heroku/python/include/python2.7 -I. -I/usr/include/postgresql -I/usr/include/postgresql/9.3/server -c psycopg/green.c -o build/temp.linux-x86_64-2.7/psycopg/green.o -Wdeclaration-after-statement
remote:            gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090306 -DHAVE_LO64=1 -I/app/.heroku/python/include/python2.7 -I. -I/usr/include/postgresql -I/usr/include/postgresql/9.3/server -c psycopg/pqpath.c -o build/temp.linux-x86_64-2.7/psycopg/pqpath.o -Wdeclaration-after-statement
remote:            gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090306 -DHAVE_LO64=1 -I/app/.heroku/python/include/python2.7 -I. -I/usr/include/postgresql -I/usr/include/postgresql/9.3/server -c psycopg/utils.c -o build/temp.linux-x86_64-2.7/psycopg/utils.o -Wdeclaration-after-statement
remote:            gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090306 -DHAVE_LO64=1 -I/app/.heroku/python/include/python2.7 -I. -I/usr/include/postgresql -I/usr/include/postgresql/9.3/server -c psycopg/bytes_format.c -o build/temp.linux-x86_64-2.7/psycopg/bytes_format.o -Wdeclaration-after-statement
remote:            gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090306 -DHAVE_LO64=1 -I/app/.heroku/python/include/python2.7 -I. -I/usr/include/postgresql -I/usr/include/postgresql/9.3/server -c psycopg/connection_int.c -o build/temp.linux-x86_64-2.7/psycopg/connection_int.o -Wdeclaration-after-statement
remote:            gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090306 -DHAVE_LO64=1 -I/app/.heroku/python/include/python2.7 -I. -I/usr/include/postgresql -I/usr/include/postgresql/9.3/server -c psycopg/connection_type.c -o build/temp.linux-x86_64-2.7/psycopg/connection_type.o -Wdeclaration-after-statement
remote:            gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090306 -DHAVE_LO64=1 -I/app/.heroku/python/include/python2.7 -I. -I/usr/include/postgresql -I/usr/include/postgresql/9.3/server -c psycopg/cursor_int.c -o build/temp.linux-x86_64-2.7/psycopg/cursor_int.o -Wdeclaration-after-statement
remote:            gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090306 -DHAVE_LO64=1 -I/app/.heroku/python/include/python2.7 -I. -I/usr/include/postgresql -I/usr/include/postgresql/9.3/server -c psycopg/cursor_type.c -o build/temp.linux-x86_64-2.7/psycopg/cursor_type.o -Wdeclaration-after-statement
remote:            gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090306 -DHAVE_LO64=1 -I/app/.heroku/python/include/python2.7 -I. -I/usr/include/postgresql -I/usr/include/postgresql/9.3/server -c psycopg/diagnostics_type.c -o build/temp.linux-x86_64-2.7/psycopg/diagnostics_type.o -Wdeclaration-after-statement
remote:            gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090306 -DHAVE_LO64=1 -I/app/.heroku/python/include/python2.7 -I. -I/usr/include/postgresql -I/usr/include/postgresql/9.3/server -c psycopg/error_type.c -o build/temp.linux-x86_64-2.7/psycopg/error_type.o -Wdeclaration-after-statement
remote:            gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090306 -DHAVE_LO64=1 -I/app/.heroku/python/include/python2.7 -I. -I/usr/include/postgresql -I/usr/include/postgresql/9.3/server -c psycopg/lobject_int.c -o build/temp.linux-x86_64-2.7/psycopg/lobject_int.o -Wdeclaration-after-statement
remote:            gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090306 -DHAVE_LO64=1 -I/app/.heroku/python/include/python2.7 -I. -I/usr/include/postgresql -I/usr/include/postgresql/9.3/server -c psycopg/lobject_type.c -o build/temp.linux-x86_64-2.7/psycopg/lobject_type.o -Wdeclaration-after-statement
remote:            gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090306 -DHAVE_LO64=1 -I/app/.heroku/python/include/python2.7 -I. -I/usr/include/postgresql -I/usr/include/postgresql/9.3/server -c psycopg/notify_type.c -o build/temp.linux-x86_64-2.7/psycopg/notify_type.o -Wdeclaration-after-statement
remote:            gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090306 -DHAVE_LO64=1 -I/app/.heroku/python/include/python2.7 -I. -I/usr/include/postgresql -I/usr/include/postgresql/9.3/server -c psycopg/xid_type.c -o build/temp.linux-x86_64-2.7/psycopg/xid_type.o -Wdeclaration-after-statement
remote:            gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090306 -DHAVE_LO64=1 -I/app/.heroku/python/include/python2.7 -I. -I/usr/include/postgresql -I/usr/include/postgresql/9.3/server -c psycopg/adapter_asis.c -o build/temp.linux-x86_64-2.7/psycopg/adapter_asis.o -Wdeclaration-after-statement
remote:            gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090306 -DHAVE_LO64=1 -I/app/.heroku/python/include/python2.7 -I. -I/usr/include/postgresql -I/usr/include/postgresql/9.3/server -c psycopg/adapter_binary.c -o build/temp.linux-x86_64-2.7/psycopg/adapter_binary.o -Wdeclaration-after-statement
remote:            gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090306 -DHAVE_LO64=1 -I/app/.heroku/python/include/python2.7 -I. -I/usr/include/postgresql -I/usr/include/postgresql/9.3/server -c psycopg/adapter_datetime.c -o build/temp.linux-x86_64-2.7/psycopg/adapter_datetime.o -Wdeclaration-after-statement
remote:            gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090306 -DHAVE_LO64=1 -I/app/.heroku/python/include/python2.7 -I. -I/usr/include/postgresql -I/usr/include/postgresql/9.3/server -c psycopg/adapter_list.c -o build/temp.linux-x86_64-2.7/psycopg/adapter_list.o -Wdeclaration-after-statement
remote:            gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090306 -DHAVE_LO64=1 -I/app/.heroku/python/include/python2.7 -I. -I/usr/include/postgresql -I/usr/include/postgresql/9.3/server -c psycopg/adapter_pboolean.c -o build/temp.linux-x86_64-2.7/psycopg/adapter_pboolean.o -Wdeclaration-after-statement
remote:            gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090306 -DHAVE_LO64=1 -I/app/.heroku/python/include/python2.7 -I. -I/usr/include/postgresql -I/usr/include/postgresql/9.3/server -c psycopg/adapter_pdecimal.c -o build/temp.linux-x86_64-2.7/psycopg/adapter_pdecimal.o -Wdeclaration-after-statement
remote:            gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090306 -DHAVE_LO64=1 -I/app/.heroku/python/include/python2.7 -I. -I/usr/include/postgresql -I/usr/include/postgresql/9.3/server -c psycopg/adapter_pint.c -o build/temp.linux-x86_64-2.7/psycopg/adapter_pint.o -Wdeclaration-after-statement
remote:            gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090306 -DHAVE_LO64=1 -I/app/.heroku/python/include/python2.7 -I. -I/usr/include/postgresql -I/usr/include/postgresql/9.3/server -c psycopg/adapter_pfloat.c -o build/temp.linux-x86_64-2.7/psycopg/adapter_pfloat.o -Wdeclaration-after-statement
remote:            gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090306 -DHAVE_LO64=1 -I/app/.heroku/python/include/python2.7 -I. -I/usr/include/postgresql -I/usr/include/postgresql/9.3/server -c psycopg/adapter_qstring.c -o build/temp.linux-x86_64-2.7/psycopg/adapter_qstring.o -Wdeclaration-after-statement
remote:            gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090306 -DHAVE_LO64=1 -I/app/.heroku/python/include/python2.7 -I. -I/usr/include/postgresql -I/usr/include/postgresql/9.3/server -c psycopg/microprotocols.c -o build/temp.linux-x86_64-2.7/psycopg/microprotocols.o -Wdeclaration-after-statement
remote:            gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090306 -DHAVE_LO64=1 -I/app/.heroku/python/include/python2.7 -I. -I/usr/include/postgresql -I/usr/include/postgresql/9.3/server -c psycopg/microprotocols_proto.c -o build/temp.linux-x86_64-2.7/psycopg/microprotocols_proto.o -Wdeclaration-after-statement
remote:            gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.6 (dt dec pq3 ext lo64)" -DPG_VERSION_HEX=0x090306 -DHAVE_LO64=1 -I/app/.heroku/python/include/python2.7 -I. -I/usr/include/postgresql -I/usr/include/postgresql/9.3/server -c psycopg/typecast.c -o build/temp.linux-x86_64-2.7/psycopg/typecast.o -Wdeclaration-after-statement
remote:            gcc -pthread -shared build/temp.linux-x86_64-2.7/psycopg/psycopgmodule.o build/temp.linux-x86_64-2.7/psycopg/green.o build/temp.linux-x86_64-2.7/psycopg/pqpath.o build/temp.linux-x86_64-2.7/psycopg/utils.o build/temp.linux-x86_64-2.7/psycopg/bytes_format.o build/temp.linux-x86_64-2.7/psycopg/connection_int.o build/temp.linux-x86_64-2.7/psycopg/connection_type.o build/temp.linux-x86_64-2.7/psycopg/cursor_int.o build/temp.linux-x86_64-2.7/psycopg/cursor_type.o build/temp.linux-x86_64-2.7/psycopg/diagnostics_type.o build/temp.linux-x86_64-2.7/psycopg/error_type.o build/temp.linux-x86_64-2.7/psycopg/lobject_int.o build/temp.linux-x86_64-2.7/psycopg/lobject_type.o build/temp.linux-x86_64-2.7/psycopg/notify_type.o build/temp.linux-x86_64-2.7/psycopg/xid_type.o build/temp.linux-x86_64-2.7/psycopg/adapter_asis.o build/temp.linux-x86_64-2.7/psycopg/adapter_binary.o build/temp.linux-x86_64-2.7/psycopg/adapter_datetime.o build/temp.linux-x86_64-2.7/psycopg/adapter_list.o build/temp.linux-x86_64-2.7/psycopg/adapter_pboolean.o build/temp.linux-x86_64-2.7/psycopg/adapter_pdecimal.o build/temp.linux-x86_64-2.7/psycopg/adapter_pint.o build/temp.linux-x86_64-2.7/psycopg/adapter_pfloat.o build/temp.linux-x86_64-2.7/psycopg/adapter_qstring.o build/temp.linux-x86_64-2.7/psycopg/microprotocols.o build/temp.linux-x86_64-2.7/psycopg/microprotocols_proto.o build/temp.linux-x86_64-2.7/psycopg/typecast.o -L/usr/lib -lpq -o build/lib.linux-x86_64-2.7/psycopg2/_psycopg.so
remote:          Running setup.py install for mimerender
remote:        
remote:          Running setup.py install for MarkupSafe
remote:            building 'markupsafe._speedups' extension
remote:            gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/app/.heroku/python/include/python2.7 -c markupsafe/_speedups.c -o build/temp.linux-x86_64-2.7/markupsafe/_speedups.o
remote:            gcc -pthread -shared build/temp.linux-x86_64-2.7/markupsafe/_speedups.o -o build/lib.linux-x86_64-2.7/markupsafe/_speedups.so
remote:          Running setup.py install for Mako
remote:            Installing mako-render script to /app/.heroku/python/bin
remote:          Running setup.py install for Jinja2
remote:          Running setup.py install for itsdangerous
remote:          Compiling /tmp/pip-build-2z5fcv/gunicorn/gunicorn/workers/_gaiohttp.py
remote:          
remote:        
remote:          Running setup.py install for Flask-SQLAlchemy
remote:          Running setup.py install for Flask-Script
remote:          Running setup.py install for Flask-Restless
remote:        
remote:          Running setup.py install for Flask-Migrate
remote:          Running setup.py install for Flask-Assets
remote:          Running setup.py install for Flask
remote:          Running setup.py install for aniso8601
remote:          Running setup.py install for alembic
remote:            Installing alembic script to /app/.heroku/python/bin
remote:        Successfully installed Flask-0.10.1 Flask-Assets-0.10 Flask-Migrate-1.3.1 Flask-RESTful-0.3.2 Flask-Restless-0.17.0 Flask-SQLAlchemy-2.0 Flask-Script-2.0.5 Jinja2-2.7.3 Mako-1.0.1 MarkupSafe-0.23 SQLAlchemy-0.9.9 Werkzeug-0.10.4 alembic-0.7.5.post2 aniso8601-0.92 gunicorn-19.3.0 itsdangerous-0.24 marshmallow-1.2.4 mimerender-0.5.5 psycopg2-2.6 python-dateutil-2.4.2 python-mimeparse-0.1.4 pytz-2015.2 six-1.9.0 webassets-0.10.1
remote: 
remote: -----> Preparing static assets
remote:        Collectstatic configuration error. To debug, run:
remote:        $ heroku run python ./manage.py collectstatic --noinput
remote: 
remote: -----> Discovering process types
remote:        Procfile declares types -> web
remote: 
remote: -----> Compressing... done, 57.0MB
remote: -----> Launching... done, v5

【问题讨论】:

  • 你的 shebang #!flask/bin/python 看起来很奇怪。

标签: python heroku flask


【解决方案1】:

确保您有一个 requirements.txt 以及 https://devcenter.heroku.com/articles/python-pip 中所述的依赖项。

【讨论】:

  • 嗨,我的 requirements.txt 文件如下:alembic==0.7.5.post2 aniso8601==0.92 Flask==0.10.1 Flask-Assets==0.10 Flask-Migrate==1.3.1 Flask-RESTful==0.3.2 Flask-Restless==0.17.0 Flask-Script==2.0.5 Flask-SQLAlchemy==2.0 gunicorn==19.3.0 itsdangerous==0.24 Jinja2==2.7.3 Mako==1.0 .1 MarkupSafe==0.23 marshmallow==1.2.4 mimerender==0.5.5 psycopg2==2.6 python-dateutil==2.4.2 python-mimeparse==0.1.4 pytz==2015.2 六==1.9.0 SQLAlchemy= =0.9.9 网络资产==0.10.1 Werkzeug==0.10.4
【解决方案2】:

Heroku 不使用您在本地使用的virutalenv。不要将其提交到源代码控制或将其推送到 heroku。使用requirements.txt 文件列出您的项目依赖项。

【讨论】:

  • 在上面添加了 requirements.txt
  • 为什么你的文件顶部有#!flask/bin/python
  • 我把它取下来了,不知道为什么我有它,但同样的问题
  • 当您将应用程序部署到 Heroku 时,您应该会看到它创建 virutalenv 并安装依赖项的输出。你看到了吗?
  • 不,我没看到,我会发布输出
猜你喜欢
  • 2020-08-06
  • 2013-03-02
  • 1970-01-01
  • 1970-01-01
  • 2021-08-04
  • 1970-01-01
  • 2021-09-08
  • 1970-01-01
  • 2019-01-30
相关资源
最近更新 更多