Fail to push to Heroku: /app/.heroku/python/bin/pip:No such file or directory

落爺英雄遲暮 提交于 2019-12-30 04:02:11

问题


I am trying to push a Django project to Heroku, but it keeps telling me that the following:

/app/.heroku/python/bin/pip: No such file or directory

The complete error message is shown below. How can I address this issue? Do I need to first install pip on Heroku?

Counting objects: 451, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (383/383), done.
Writing objects: 100% (451/451), 1.07 MiB | 349.00 KiB/s, done.
Total 451 (delta 87), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: -----> Installing python-3.5.1
remote: -----> Installing pip
remote: -----> Installing requirements with pip
remote:        /app/tmp/buildpacks/779a8bbfbbe7e1b715476c0b23fc63a2103b3e4131eda558669aba8fb5e6e05682419376144189b29beb5dee6d7626b4d3385edb0954bffea6c67d8cf622fd51
/bin/steps/pip-install: line 5: /app/.heroku/python/bin/pip: No such file or directory
remote:  !     Push rejected, failed to compile Python app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !   Push rejected to rocky-tor-70537.
remote:
To https://git.heroku.com/rocky-tor-70537.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/rocky-tor-70537.git'

My requirements.txt file is empty, as shown below.

# this is for Heroku and other servers.
# Locally, you should install requirements_base.txt
-r requirements_server.txt

My requirements_server.txt is as follows:

-r requirements_base.txt
# packages that are unnecessary on Windows/Mac local dev environments, or don't install properly
psycopg2>=2.5.1

My requirements_base.txt is as follows:

appdirs==1.4.3
asgi-redis==0.14.1
asgiref==0.14.0
autobahn==0.16.0
Babel==2.3.4
boto==2.42.0
channels==0.17.3
colorama==0.3.7
contextlib2==0.5.4
coverage==4.2
daphne==0.14.3
dj-database-url==0.4.1
Django==1.8.8
django-countries==4.0
django-easymoney==0.7.1
django-floppyforms==1.7.0
django-idmap==0.4.1
django-vanilla-views==1.0.4
djangorestframework==3.4.6
honcho==0.7.1
huey==1.2.0
IPy==0.83
mock==2.0.0
msgpack-python==0.4.8
otree-core==1.2.8
otree-save-the-change==1.1.3
packaging==16.8
pbr==1.10.0
py==1.4.31
pyparsing==2.2.0
pytest==2.9.2
pytest-django==3.0.0
python-redis-lock==3.2.0
pytz==2016.6.1
raven==5.25.0
redis==2.10.5
requests==2.11.1
schema==0.6.2
six==1.10.0
Twisted==16.2.0
txaio==2.5.1
unicodecsv==0.14.1
whitenoise==3.2.1
ws4py==0.3.5
XlsxWriter==0.9.3
zope.interface==4.2.0

回答1:


I ran into this issue recently and was able to adjust it by changing the python version in the runtime.txt.

Changing to

python-3.5.2

But based off your requirements that you have listed, it seems like you are never getting to the requirements_base.txt.

In your requirements_server.txt file, change it so that:

-r requirements_base.txt 

is listed there.




回答2:


I simply had two typos in my runtime.txt

Make sure it says python-3.6.1 and not Python-3.6.1 or python 3.6.1

The error message is pretty bad. May this post save someone 30 minutes.




回答3:


Looks like Heroku now supports only 3.6.1 and 2.7.13 Python versions.

https://devcenter.heroku.com/articles/python-runtimes#supported-python-runtimes




回答4:


If you are using the default heroku buildpack I would guess that the requirements.txt file in your project folder is missing.




回答5:


I had the same problem on Ubuntu 16.04 and after manually installing Heroku CLI, using

wget https://cli-assets.heroku.com/branches/stable/heroku-REPLACE_ME_OS-REPLACE_ME_ARCH.tar.gz -O heroku.tar.gz

mkdir -p /usr/local/lib

tar -xvzf heroku.tar.gz -C /usr/local/lib

/usr/local/lib/heroku/install

it worked like a charm.

In the folder I have 4 files. One is python script, second is procfile (no extension) with content web: gunicorn skripta1:app. Third is requirements.txt with:

appdirs==1.4.3
bokeh==0.12.5
click==6.7
Flask==0.12.2
gunicorn==19.7.1
itsdangerous==0.24
Jinja2==2.9.6
MarkupSafe==1.0
numpy==1.12.1
packaging==16.8
pandas==0.20.1
pandas-datareader==0.4.0
pyparsing==2.2.0
python-dateutil==2.6.0
pytz==2017.2
PyYAML==3.12
requests==2.14.2
requests-file==1.4.2
requests-ftp==0.3.1
six==1.10.0
tornado==4.5.1
Werkzeug==0.12.2 

And fourth is runtime.txt with python-3.5.2




回答6:


According to Heroku documentation, the only two officially supported python runtimes are 2.7.13, and 3.6.1. I recently had the same issue with oTree deployment in heroku, but as soon as I changed runtime.txt to python-3.6.1 everything went smoothly.




回答7:


Oh dear - I removed a blank line in my requirements/production.txt in order to try and change the line number and everything started working (or rather on to my next completely different error)




回答8:


I ran into this same problem on Windows trying to deploy a Python app to Heroku. Turns out it was a file encoding problem. Depending on how you create Procfile, requirements.txt and runtime.txt your encoding may vary.

Assuming you're running Windows, use PowerShell. Get the following PowerShell Function and paste it in to your PowerShell console. Using this, you can check your file encoding: get-fileencoding requirements.txt If it comes back anything besides ascii that's probably the issue. In my case, my three files were all unicode. I just did this to force them to ASCII: 'python-3.6.1' | out-file -en ascii runtime.txt You can also use an editor and then save the file using ASCII encoding.

Once I made this change to my Procfile, requirements.txt and runtime.txt I was able to successfully deploy to Heroku.




回答9:


I was switching from app engine to heroku and had a setup.cfg file in the root directory with following content:

[install]
prefix= 

It caused this issues while deployment. After removing everything went well.



来源:https://stackoverflow.com/questions/44032490/fail-to-push-to-heroku-app-heroku-python-bin-pipno-such-file-or-directory

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