【发布时间】:2020-07-08 02:18:04
【问题描述】:
我第一次尝试将烧瓶应用程序部署到 heroku。当我做 git push heroku master 我得到以下错误
cp: cannot stat '/tmp/cache/requirements.txt': No such file or directory
我的 procfile 看起来像这样
web: gunicorn app.py
运行时.txt
python-3.6.1
requirements.txt
bokeh==2.1.1
certifi==2020.6.20
chardet==3.0.4
click==7.1.2
cssmin==0.2.0
Flask==1.1.2
Flask-Assets==2.0
Flask-SQLAlchemy==2.4.3
gunicorn==20.0.4
httplib2==0.18.1
idna==2.9
isort==4.3.21
itsdangerous==1.1.0
Jinja2==2.11.2
jsmin==2.2.2
lazy-object-proxy==1.4.3
libsass==0.20.0
MarkupSafe==1.1.1
mccabe==0.6.1
numpy==1.19.0
opensecrets-crpapi==0.2.2
packaging==20.4
pandas==1.0.5
Pillow==7.2.0
pylint==2.5.3
pyparsing==2.4.7
python-dateutil==2.8.1
python-dotenv==0.13.0
pytz==2020.1
PyYAML==5.3.1
requests==2.24.0
six==1.15.0
SQLAlchemy==1.3.18
toml==0.10.1
tornado==6.0.4
typed-ast==1.4.1
typing-extensions==3.7.4.2
urllib3==1.25.9
webassets==2.0
Werkzeug==1.0.1
whitenoise==5.1.0
wrapt==1.12.1
这是完整的错误日志
remote: -----> Python app detected
remote: cp: cannot stat '/tmp/cache/requirements.txt': No such file or directory
remote: -----> Installing python-3.6.11
remote: -----> Installing pip
remote: -----> Installing SQLite3
remote: -----> Installing requirements with pip
remote: Obtaining file:///tmp/cache (from -r /tmp/cache/requirements.txt (line 1))
remote: ERROR: Command errored out with exit status 1:
remote: command: /app/.heroku/python/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/cache/setup.py'"'"'; __file__='"'"'/tmp/cache/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info
remote: cwd: /tmp/cache/
remote: Complete output (8 lines):
remote: running egg_info
remote: creating finalproject.egg-info
remote: writing finalproject.egg-info/PKG-INFO
remote: writing dependency_links to finalproject.egg-info/dependency_links.txt
remote: writing requirements to finalproject.egg-info/requires.txt
remote: writing top-level names to finalproject.egg-info/top_level.txt
remote: writing manifest file 'finalproject.egg-info/SOURCES.txt'
remote: error: package directory 'application' does not exist
remote: ----------------------------------------
remote: ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
remote: ! Push rejected, failed to compile Python app.
app = Flask(__name__)
app.config.from_pyfile('settings.py')
##where to find the database and initialize SQLAlchemy
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///congress.sqlite3'
db = SQLAlchemy(app)
##option to tell SQLALchemy that we’re way too lazy to do that, and for every model it should just
#look at the columns that already exist in the table. This is called reflecting
db.Model.metadata.reflect(db.engine)
class Congress(db.Model):
__tablename__ = 'sen'
__table_args__ = { 'extend_existing': True }
id = db.Column(db.Text, primary_key=True)
## access sass
app.wsgi_app = SassMiddleware(app.wsgi_app, {
'app': ('static/assets/sass', 'app/static/assets/css/light-bootstrap-dashboard.css', 'app/static/assets/css/light-bootstrap-dashboard.css')
})
# Ensure templates are auto-reloaded
app.config["TEMPLATES_AUTO_RELOAD"] = True
# Custom filter
app.jinja_env.filters["usd"] = usd
from app import routes```
【问题讨论】:
-
你能展示一下你的项目目录的结构吗?当您的 procfile 出现问题时,通常会发生这种情况。
-
我已经包含了一个指向我的项目目录图片的链接。 ty
-
您的 Procfile 必须如下所示
web: gunicorn app:nameofyourappnameofyourapp 是您在 app.py 中使用的名称 -
我尝试了 app:app.py 也 app:app ,但不幸的是都没有成功。你还有什么建议
-
请出示您的应用 py 文件。另外我假设您正在使用您的 app.py 文件来运行烧瓶应用程序
标签: flask heroku deployment