无法使用Heroku安装软件包或升级点子

时间:2018-11-06 01:11:33

标签: django heroku pip

我正在使用GitHub和Heroku运行Django应用。该应用程序在本地可以正常运行,但是在将其通过GitHub推送到Heroku时遇到了问题。我认为我可以将其归结为无法使用requirements.txt或常规点设置的东西。具体来说,我一直在尝试安装Django-Bootstrap4。在需求文件中。

我当然不理解这个过程,而且我很可能甚至没有问正确的问题。但是我尝试遵循这里找到的所有文档:https://devcenter.heroku.com/articles/python-pip

当我在本地虚拟环境中时,一切看起来都很好。然后做完:

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

它似乎已安装,但随后运行:

> heroku run pip list

什么都没有改变。 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"

添加日志:

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.

3 个答案:

答案 0 :(得分:1)

heroku run创建一个一次性Dyno并在其中运行命令,您的更改将不会保留。

您实际上不需要pip install自己。 Doc here

  

要通过pip在Heroku上指定Python包依赖关系,请添加一个pip   需求文件,名为requirements.txt到您的根目录   存储库。

答案 1 :(得分:1)

首先,运行pip install django-bootstrap4

其次,运行pip freeze > requirements.txt

然后添加并提交-git add requirements.txt && git commit -m 'added django-bootstrap4 && git push heroku master

这会将软件包安装在您的Heroku应用中。

答案 2 :(得分:0)

这解决了我的问题:https://stackoverflow.com/a/52821649/4490230

关于使用pip运行最新版本的pipenv的问题。具体来说,我不仅必须在虚拟环境中进行降级,还必须在根目录中进行降级。