I've been struggling with Heroku for a little while and I can't quite seem to figure my problem out. I have a runtime.txt in the root directory of my Python project that I am trying to deploy to Heroku, yet Heroku cannot find it for some reason. Every time I try deploying the app (I just keep creating/deleting new apps on Heroku) it just sends me this message:
-----> No runtime.txt provided; assuming python-2.7.4.
It makes no sense because my runtime.txt is clearly in the same directory as my Procfile and requirements.txt yet it has no problem finding those.
For good measure, here is my runtime.txt:
python-3.3.2
My project is based in Python 3.3, so I can't just go with the default python-2.7.4.
This may be a weird special case, I couldn't find anybody else with my problem while Googling. Thanks in advance!
EDIT: For anyone who may have this problem in the future, a simple reboot fixed the problem for me. Don't know why I didn't try it earlier.
Related
I have a Python trading bot which I want to run in cloud with the help of Heroku. The Python code works just fine, but when I try to push the files after add and commit, I am getting error which says heroku cannot detect the buildpack and heroku pre-receive hook declined
I tried to fix it, but nothing seems to work. But then I tried to deploy not by pushing it from my computer, but by uploading it to GitHub and connecting my GitHub account to Heroku account.
Connecting both accounts went well, but I get this error when I tried to deploy the files:
-----> Building on the Heroku-20 stack
-----> Determining which buildpack to use for this app
! No default language could be detected for this app.
HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.
See https://devcenter.heroku.com/articles/buildpacks
! Push failed
The error seems pretty straight forward and directs us to visit a website. I did try some of the stuff mentioned in the website, but maybe I am doing it wrong.
Till now what I understand is Heroku is not able to detect the language I am using which is Python. How can I fix this?
I think there is a pretty simple solution if you have the access to the Heroku account used to deploy this app.
Direct to the app page and go under the Settings tab, you should be able to find a Buildpacks section where you can add your buildpack if not detected automatically during deployment.
Click Add Buildpack and choose Python as your custom buildpack. Problem should be solved.
P.S. If you don't have requirements.txt in your folder, consider adding all the packages along with their versions used for your Python Flask app to this file. For example:
Flask==2.0.2
Flask-Admin==1.5.8
Flask-Bcrypt==0.7.1
Flask-DebugToolbar==0.11.0
Flask-SQLAlchemy==2.5.1
Flask-WTF==1.0.0
Im using django 3 and Python 3.7.4
I don't have any issues with the deployment and the project is working, it's just the first time I face this issue.
Normally when deploying to Heroku all packages in the requirements file get installed during the first deployment process, and any further deployment will only update or install the new packages the get added.
In my case, everytime I deploy, heroku is installing the whole packages again.
Please advise if there is a way to handle this issue.
thanks
This looks like a current issue with the Heroku python buildpack. As long as the issue persists the cache is cleared on every build, since the sqlite3 check is broken. Suggest upvoting the issue on GitHub.
Im using django 3 and Python 3.7.4
I don't have any issues with the deployment and the project is working, it's just the first time I face this issue.
Normally when deploying to Heroku all packages in the requirements file get installed during the first deployment process, and any further deployment will only update or install the new packages the get added.
In my case, everytime I deploy, heroku is installing the whole packages again.
Please advise if there is a way to handle this issue.
thanks
This looks like a current issue with the Heroku python buildpack. As long as the issue persists the cache is cleared on every build, since the sqlite3 check is broken. Suggest upvoting the issue on GitHub.
When I run my app locally, everything works, but when I try to deploy to Heroku, I get this error:
ModuleNotFoundError: No module named 'stripe'
I've read some other answers to similar issues and it seems like maybe my virtual environment is running a different version of Python than the one on Heroku, or something along those lines?
My Python version is 3.6.5
I do have a runtime.txt file with the following in it, which I thought was setting the python version for my Heroku app:
python-3.6.5
I read this SO thread, but I didn't really understand the part about the PYTHONPATH - Importing Stripe into Django - NameError
If anyone can help steer me in the right direction or has an idea of what I could try, I'd really appreciate it!
Thanks!
Add stripe to requirements.txt file in the root of your repository. You can read more about it here.
This is an old app, running since about two years on Heroku. Now suddenly, when I deploy (standard git push), it breaks the Python interpreter, both on regular and one-off dynos. Here's what it looks like:
$ heroku run python
Running `python` attached to terminal... up, run.8338
python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory
Further pushes, heroku restart, scaling the dynos to zero and back up, that all doesn't fix it.
The only changes contained in this deployment which I could imagine being related to this problem are: gevent upgraded from 0.13.6 to 1.0.1 and the introduction of a runtime.txt (before there was none, resulting in 2.7.4, now there's one for 2.7.6).
I rolled all of this back to no effect, however. In fact, I went back about 30 commits (the deployment contained maybe five) and pushed that and the app is still broken.
Rolling back with heroku rollback is the only way I've found to take the app back into a usable state. But of course that doesn't help me going forward.
What might cause this? Can I somehow rebuild my whole app environment from scratch?
EDIT 1: I opened a shell in a one-off dyno and I can see the libpython2.7.so.1.0 file there:
/ $ ls -la /app/.heroku/python/lib/libpython2.7.so.1.0
-r-x------ 1 u49295 49295 5694572 2014-06-03 23:39 /app/.heroku/python/lib/libpython2.7.so.1.0
Of course I don't know if that's where it's supposed to be.
Somehow certain apps did not upgrade properly. A temporary fix to locate the correct python library:
heroku config:set LD_LIBRARY_PATH=/app/.heroku/python/lib
Kenneth Reitz from the Python team here.
So, we're rolling out security updates to the version of Python that we have installed on our base system. Customers shouldn't be affected by this in any way, because their apps use their own version of Python, and because we set local runtime-specific (such as LD_LIBRARY_PATH) in a .profile.d scripts, outside of user-set configuration.
However, we allow power users to override these environment variables with $ heroku config. That's basically what the application was doing — although, not knowingly. This was an accidental side-effect of a much, much older Heroku. In older days, we couldn't have any runtime-specific configuration without being a part of user configuration. This is why your application had an LD_LIBRARY_PATH config set, and this is what caused this bug.
Because of this, I've disabled the overridability of LD_LIBRARY_PATH for Python apps, and all should be well moving forward.
Thanks for being a part of the gradual rollout process, and thanks for helping us get to the bottom of this regression. I'm very sorry for the inconvenience.
Are you using the default Python buildpack? Heroku is in the process of updating the Stack image, and especially if you're not using a current buildpack, there may be incompatibilities.
To see if you're using a default buildpack, run
$ heroku config | grep BUILDPACK_URL
Please contact Heroku support if you think this might be the cause.