gpt4 book ai didi

django - 无法使用 Heroku 安装软件包或升级 pip

转载 作者:行者123 更新时间:2023-12-04 11:47:36 24 4
gpt4 key购买 nike

我正在使用 GitHub 和 Heroku 来运行我的 Django 应用程序。该应用程序在本地按预期工作,但在将其(通过 GitHub)推送到 Heroku 时遇到了问题。我想我把它归结为一些不适用于 requirements.txt 或一般 pip 设置的东西。具体来说,我一直在尝试安装 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

要求.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

文件
[[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.

最佳答案

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

你实际上不需要pip install你自己。 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.

关于django - 无法使用 Heroku 安装软件包或升级 pip,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53164484/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com