Pyton application cant deploy to heroku

馋奶兔 提交于 2020-04-16 05:48:35

问题


I find this error whiledeploying it to heroku. cp: cannot create regular file '/app/tmp/cache/.heroku/requirements.txt': No such file or directory

Project's procfile: web: python app.py

project's runtime.txt python-3.7.6

project's requirements.txt


    APScheduler==3.6.3
    certifi==2019.11.28
    Click==7.0
    colorhash==1.0.2
    configparser==4.0.2
    cycler==0.10.0
    Flask==1.1.1
    Flask-Cors==3.0.8
    gunicorn==20.0.4
    itsdangerous==1.1.0
    Jinja2==2.11.0
    kiwisolver==1.1.0
    kneed==0.5.3
    MarkupSafe==1.1.1
    numpy==1.18.1
    psutil==5.7.0
    pyparsing==2.4.6
    python-dateutil==2.8.1
    six==1.14.0
    SQLAlchemy==1.3.13
    tzlocal==2.0.0
    Werkzeug==0.16.1
    wincertstore==0.2
    chardet==3.0.4
    decorator==4.4.1
    entrypoints==0.3
    idna==2.8
    jsonschema==3.2.0
    matplotlib==3.1.3
    mccabe==0.6.1
    pandas==1.0.1
    pytz==2019.3
    pyzmq==18.1.1
    requests==2.22.0
    soupsieve==1.9.5
    urllib3==1.25.8
    webencodings==0.5.1
    widgetsnbextension==3.5.1

Anyone experienced this ? please guide me if so.


回答1:


It would have been great if you showed the script that you are trying to run. Without that, I am assuming the error may be related to the wrong configuration in procfile.

Try replacing web with worker in your Procfile.

If you have a "web" process type in your Procfile, the dyno running that process must bind to its assigned $PORT within 60 seconds (by default), in order to be able to respond to incoming web requests over http/s. If it doesn't, Heroku takes down the dyno as explained here.




回答2:


I don't know if this is your case anyway this error can happen if you make a mistake when specifying which file to start in the Procfile.

For example in your case if instead of app.py your filename is different.




回答3:


Try this,

on your cmd prompt:

pip install gunicorn
pip install whitenoise
pip freeze>requirements.txt

In your project main folder add a file named Procfile (no extention), and inside this file type:

web: gunicorn your_project_(main_folder)_name.wsgi

Note: In your procfile you typed app.py, but it should rather be my_project.wsgi . Maybe this is sufficient to solve your problem.

In your project main folder add a folder named staticfiles, and inside this folder add a file named __init__.py and leave it blank.

Then in your settings.py add:

STATICSTORAGE = "Whitenoise.storage.CompressedManifestStaticFilesStorage"

Again in settings.py, inside MIDDLEWARE, add:

'whitenoise.middleware.WhiteNoiseMiddleware',

Finally on your cmd prompt:

git add .
git commit -m "whatever you want"
git push heroku master

If I am correct, the first time you will push your code to Heroku, it will tell again

cannot create regular file '/app/tmp/cache/.heroku/requirements.txt': No such file or directory

but then it will collect all the static files and then succeed in deploying.

From next time, it will no more print out all the static files collected.



来源:https://stackoverflow.com/questions/60910434/pyton-application-cant-deploy-to-heroku

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!