Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not able to install packages or upgrade pip with Heroku

Tags:

pip

django

heroku

I'm using GitHub and Heroku to run my Django app. The app works as expected locally but I'm running into problems when pushing (via GitHub) it up to Heroku. I think I boiled it down to something not working with requirements.txt or the general pip set up. Specifically, I've been trying to install Django-Bootstrap4. It is in the requirements file.

I definitely don't understand this process and I very well might not even be asking the right questions. But I've tried following all of the documentation found here: https://devcenter.heroku.com/articles/python-pip.

When I'm in the virtual environment locally, everything looks fine. Then after doing:

> heroku login
> heroku run pip install django-bootstrap4 (or pip or pandas)

It seems to install, but then running:

> heroku run pip list

nothing has changed. TIA

requirements.txt

certifi==2018.8.24
chardet==3.0.4
dj-database-url==0.5.0
Django==2.1.2
django-bootstrap4==0.0.7
django-heroku==0.3.1
django-registration-redux==2.5
gunicorn==19.9.0
idna==2.7
psycopg2==2.7.5
pytz==2018.5
requests==2.19.1
urllib3==1.23
whitenoise==4.1

Pipfile

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]

[dev-packages]

[requires]
python_version = "3.6"

Adding Log:

2018-11-06T02:34:49.915341+00:00 app[web.1]: Traceback (most recent call last):
2018-11-06T02:34:49.915343+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2018-11-06T02:34:49.915345+00:00 app[web.1]: worker.init_process()
2018-11-06T02:34:49.915346+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 129, in init_process
2018-11-06T02:34:49.915347+00:00 app[web.1]: self.load_wsgi()
2018-11-06T02:34:49.915349+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
2018-11-06T02:34:49.915350+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2018-11-06T02:34:49.915351+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
2018-11-06T02:34:49.915352+00:00 app[web.1]: self.callable = self.load()
2018-11-06T02:34:49.915354+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
2018-11-06T02:34:49.915355+00:00 app[web.1]: return self.load_wsgiapp()
2018-11-06T02:34:49.915356+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
2018-11-06T02:34:49.915357+00:00 app[web.1]: return util.import_app(self.app_uri)
2018-11-06T02:34:49.915358+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 350, in import_app
2018-11-06T02:34:49.915359+00:00 app[web.1]: __import__(module)
2018-11-06T02:34:49.915360+00:00 app[web.1]: File "/app/app/wsgi.py", line 7, in <module>
2018-11-06T02:34:49.915362+00:00 app[web.1]: application = get_wsgi_application()
2018-11-06T02:34:49.915363+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
2018-11-06T02:34:49.915364+00:00 app[web.1]: django.setup(set_prefix=False)
2018-11-06T02:34:49.915365+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
2018-11-06T02:34:49.915366+00:00 app[web.1]: apps.populate(settings.INSTALLED_APPS)
2018-11-06T02:34:49.915367+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/registry.py", line 89, in populate
2018-11-06T02:34:49.915368+00:00 app[web.1]: app_config = AppConfig.create(entry)
2018-11-06T02:34:49.915369+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/config.py", line 90, in create
2018-11-06T02:34:49.915370+00:00 app[web.1]: module = import_module(entry)
2018-11-06T02:34:49.915372+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
2018-11-06T02:34:49.915373+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2018-11-06T02:34:49.915426+00:00 app[web.1]: ModuleNotFoundError: No module named 'bootstrap4'
2018-11-06T02:34:49.915794+00:00 app[web.1]: [2018-11-06 02:34:49 +0000] [11] [INFO] Worker exiting (pid: 11)
2018-11-06T02:34:49.919437+00:00 app[web.1]: [2018-11-06 02:34:49 +0000] [10] [ERROR] Exception in worker process
2018-11-06T02:34:49.919439+00:00 app[web.1]: Traceback (most recent call last):
2018-11-06T02:34:49.919441+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2018-11-06T02:34:49.919443+00:00 app[web.1]: worker.init_process()
2018-11-06T02:34:49.919444+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 129, in init_process
2018-11-06T02:34:49.919446+00:00 app[web.1]: self.load_wsgi()
2018-11-06T02:34:49.919447+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
2018-11-06T02:34:49.919448+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2018-11-06T02:34:49.919450+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
2018-11-06T02:34:49.919451+00:00 app[web.1]: self.callable = self.load()
2018-11-06T02:34:49.919453+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
2018-11-06T02:34:49.919454+00:00 app[web.1]: return self.load_wsgiapp()
2018-11-06T02:34:49.919456+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
2018-11-06T02:34:49.919458+00:00 app[web.1]: return util.import_app(self.app_uri)
2018-11-06T02:34:49.919459+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 350, in import_app
2018-11-06T02:34:49.919461+00:00 app[web.1]: __import__(module)
2018-11-06T02:34:49.919462+00:00 app[web.1]: File "/app/app/wsgi.py", line 7, in <module>
2018-11-06T02:34:49.919464+00:00 app[web.1]: application = get_wsgi_application()
2018-11-06T02:34:49.919465+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
2018-11-06T02:34:49.919467+00:00 app[web.1]: django.setup(set_prefix=False)
2018-11-06T02:34:49.919469+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
2018-11-06T02:34:49.919470+00:00 app[web.1]: apps.populate(settings.INSTALLED_APPS)
2018-11-06T02:34:49.919472+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/registry.py", line 89, in populate
2018-11-06T02:34:49.919473+00:00 app[web.1]: app_config = AppConfig.create(entry)
2018-11-06T02:34:49.919474+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/config.py", line 90, in create
2018-11-06T02:34:49.919476+00:00 app[web.1]: module = import_module(entry)
2018-11-06T02:34:49.919477+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
2018-11-06T02:34:49.919479+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2018-11-06T02:34:49.919480+00:00 app[web.1]: ModuleNotFoundError: No module named 'bootstrap4'
2018-11-06T02:34:49.920093+00:00 app[web.1]: [2018-11-06 02:34:49 +0000] [10] [INFO] Worker exiting (pid: 10)
2018-11-06T02:34:50.079130+00:00 app[web.1]: [2018-11-06 02:34:50 +0000] [4] [INFO] Shutting down: Master
2018-11-06T02:34:50.079281+00:00 app[web.1]: [2018-11-06 02:34:50 +0000] [4] [INFO] Reason: Worker failed to boot.
like image 935
Pawel Avatar asked Nov 06 '18 01:11

Pawel


2 Answers

heroku run creates an one-off Dyno and runs your command in it, your changes wouldn't be persisted.

You actually don't need to pip install yourself. Doc here

To specify Python package dependencies on Heroku via pip, add a pip requirements file named requirements.txt to the root of your repository.

like image 112
Siyu Avatar answered Nov 05 '22 11:11

Siyu


First, run pip install django-bootstrap4

Secondly, run pip freeze > requirements.txt

Then add and commit - git add requirements.txt && git commit -m 'added django-bootstrap4 && git push heroku master

This will install the package in your Heroku app.

like image 42
joshlsullivan Avatar answered Nov 05 '22 11:11

joshlsullivan