简体   繁体   English

为什么我在铁路中部署 Django 应用程序时会出现此错误?

[英]Why do I get this error when I deploy a Django App in Railway?

There is a problem when I deploy a Django app in Railway, Railway is an infrastructure platform that is very similar to Heroku and it uses debian, this is the error that is in the logs.当我在铁路中部署 Django 应用程序时出现问题,铁路是一个与 Heroku 非常相似的基础设施平台,它使用 debian,这是日志中的错误。

#10 16.69   Using cached selenium-4.1.0-py3-none-any.whl (958 kB)
#10 16.75 Collecting six==1.16.0
 
#10 16.75   Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
#10 16.78 Collecting sniffio==1.2.0
#10 16.78   Using cached sniffio-1.2.0-py3-none-any.whl (10 kB)
#10 16.83 Collecting sortedcontainers==2.4.0
#10 16.83   Using cached sortedcontainers-2.4.0-py2.py3-none-any.whl (29 kB)
#10 16.89 Collecting soupsieve==2.2.1
 
#10 16.89   Using cached soupsieve-2.2.1-py3-none-any.whl (33 kB)
#10 16.93 Collecting sqlparse==0.4.2
#10 16.93   Using cached sqlparse-0.4.2-py3-none-any.whl (42 kB)
 
#10 17.07 Collecting tqdm==4.62.3
#10 17.08   Using cached tqdm-4.62.3-py2.py3-none-any.whl (76 kB)
#10 17.12 Collecting trio==0.19.0
#10 17.12   Using cached trio-0.19.0-py3-none-any.whl (356 kB)
#10 17.16 Collecting trio-websocket==0.9.2
 
#10 17.16   Using cached trio_websocket-0.9.2-py3-none-any.whl (16 kB)
#10 17.23 Collecting twine==3.4.2
#10 17.24   Using cached twine-3.4.2-py3-none-any.whl (34 kB)
#10 17.28 Collecting tzdata==2022.1
 
#10 17.29   Using cached tzdata-2022.1-py2.py3-none-any.whl (339 kB)
#10 17.38 Collecting urllib3==1.26.6
#10 17.38   Using cached urllib3-1.26.6-py2.py3-none-any.whl (138 kB)
#10 17.41 Collecting webencodings==0.5.1
 
#10 17.42   Using cached webencodings-0.5.1-py2.py3-none-any.whl (11 kB)
#10 17.47 Collecting whitenoise==6.2.0
#10 17.47   Using cached whitenoise-6.2.0-py3-none-any.whl (19 kB)
#10 17.51 Collecting wsproto==1.0.0
#10 17.51   Using cached wsproto-1.0.0-py3-none-any.whl (24 kB)
 
#10 17.57 Collecting zipp==3.6.0
#10 17.57   Using cached zipp-3.6.0-py3-none-any.whl (5.3 kB)
 
#10 18.00 Collecting psycopg2
 
#10 18.00   Using cached psycopg2-2.9.3.tar.gz (380 kB)
#10 18.09   Preparing metadata (setup.py): started
 
#10 18.38   Preparing metadata (setup.py): finished with status 'error'
#10 18.39   error: subprocess-exited-with-error
#10 18.39
#10 18.39   × python setup.py egg_info did not run successfully.
#10 18.39   │ exit code: 1
#10 18.39   ╰─> [23 lines of output]
#10 18.39       running egg_info
#10 18.39       creating /tmp/pip-pip-egg-info-bw0tcpyi/psycopg2.egg-info
#10 18.39       writing /tmp/pip-pip-egg-info-bw0tcpyi/psycopg2.egg-info/PKG-INFO
#10 18.39       writing dependency_links to /tmp/pip-pip-egg-info-bw0tcpyi/psycopg2.egg-info/dependency_links.txt
#10 18.39       writing top-level names to /tmp/pip-pip-egg-info-bw0tcpyi/psycopg2.egg-info/top_level.txt
#10 18.39       writing manifest file '/tmp/pip-pip-egg-info-bw0tcpyi/psycopg2.egg-info/SOURCES.txt'
#10 18.39
#10 18.39       Error: pg_config executable not found.
#10 18.39
#10 18.39       pg_config is required to build psycopg2 from source.  Please add the directory
#10 18.39       containing pg_config to the $PATH or specify the full executable path with the
#10 18.39       option:
#10 18.39
#10 18.39           python setup.py build_ext --pg-config /path/to/pg_config build ...
#10 18.39
#10 18.39       or with the pg_config option in 'setup.cfg'.
#10 18.39
#10 18.39       If you prefer to avoid building psycopg2 from source, please install the PyPI
#10 18.39       'psycopg2-binary' package instead.
#10 18.39
#10 18.39       For further information please check the 'doc/src/install.rst' file (also at
#10 18.39       <https://www.psycopg.org/docs/install.html>;).
#10 18.39
#10 18.39       [end of output]
#10 18.39
#10 18.39   note: This error originates from a subprocess, and is likely not a problem with pip.
#10 18.39 error: metadata-generation-failed
#10 18.39
#10 18.39 × Encountered error while generating package metadata.
 
#10 18.39 ╰─> See above for output.
#10 18.39
#10 18.39 note: This is an issue with the package mentioned above, not pip.
#10 18.39 hint: See above for details.
#10 18.40 WARNING: You are using pip version 22.0.4; however, version 22.1.2 is available.
#10 18.40 You should consider upgrading via the '/opt/venv/bin/python -m pip install --upgrade pip' command.
 
#10 ERROR: executor failed running [/bin/bash -ol pipefail -c python -m venv /opt/venv && . /opt/venv/bin/activate && pip install -r requirements.txt]: exit code: 1
-----
> [stage-0 6/9] RUN --mount=type=cache,id=s/d3b41cd2-3817-4a81-ba7d-ff021a7d5a6f-/root/.cache/pip,target=/root/.cache/pip python -m venv /opt/venv && . /opt/venv/bin/activate && pip install -r requirements.txt:
-----
executor failed running [/bin/bash -ol pipefail -c python -m venv /opt/venv && . /opt/venv/bin/activate && pip install -r requirements.txt]: exit code: 1
 
Error: Docker build failed

The error could be "Error: pg_config executable not found.", so I have looked up the error in Google, and I got that I have to change the library "psycopg2" to "psycopg2-binary", but I still get the same error.错误可能是“错误:找不到 pg_config 可执行文件。”,所以我在 Google 中查找了错误,我知道我必须将库“psycopg2”更改为“psycopg2-binary”,但我仍然得到相同的结果错误。

After I tried a "template" in railway, which is like configurations for each framework, and it brings a sample app to test with, in this case, it was a Django app, in that app I saw that the dependency "psycopg2" was the version "2.8.6", and it was working, so I also replaced the version "2.9.3" to "2.8.6", but with the same result, even with replacing it with the dependency "psycopg2-binary".在我在铁路中尝试了一个“模板”之后,就像每个框架的配置一样,它带来了一个示例应用程序进行测试,在这种情况下,它是一个 Django 应用程序,在那个应用程序中我看到依赖项“psycopg2”是版本“2.8.6”,它正在工作,所以我也将版本“2.9.3”替换为“2.8.6”,但结果相同,即使用依赖项“psycopg2-binary”替换它也是如此。

This is the requirement.txt file:这是 requirements.txt 文件:

asgiref==3.5.2
async-generator==1.10
attrs==21.4.0
backports.zoneinfo==0.2.1
beautifulsoup4==4.10.0
bleach==4.1.0
cached-property==1.5.2
certifi==2021.5.30
cffi==1.15.0
charset-normalizer==2.0.6
cloudinary==1.29.0
colorama==0.4.4
coverage==6.4.1
cryptography==36.0.1
dj-database-url==0.5.0
Django==4.0.4
django-environ==0.8.1
django-heroku==0.3.1
docutils==0.17.1
et-xmlfile==1.1.0
frozendict==2.0.6
genanki==0.11.0
h11==0.13.0
idna==3.2
importlib-metadata==4.8.1
keyring==23.2.1
numpy==1.22.3
openpyxl==3.0.9
outcome==1.1.0
packaging==21.0
pandas==1.4.2
pkginfo==1.7.1
psycopg2-binary==2.8.6
pycparser==2.21
Pygments==2.10.0
pyOpenSSL==22.0.0
pyparsing==3.0.0
pystache==0.6.0
python-dateutil==2.8.2
pytz==2022.1
pywin32-ctypes==0.2.0
PyYAML==5.4.1
readme-renderer==30.0
requests==2.26.0
requests-toolbelt==0.9.1
rfc3986==1.5.0
selenium==4.1.0
six==1.16.0
sniffio==1.2.0
sortedcontainers==2.4.0
soupsieve==2.2.1
sqlparse==0.4.2
tqdm==4.62.3
trio==0.19.0
trio-websocket==0.9.2
twine==3.4.2
tzdata==2022.1
urllib3==1.26.6
webencodings==0.5.1
whitenoise==6.2.0
wsproto==1.0.0
zipp==3.6.0

Is there some idea about what is happening?对正在发生的事情有一些想法吗?

Running johnnydep on your requirements.txt, shows that django-heroku depends on psycopg2 :在你的 requirements.txt 上运行johnnydep ,表明django-heroku依赖于psycopg2

>>> johnnydep django-heroku
2022-07-19 17:03:28 [info     ] init johnnydist                [johnnydep.lib] dist=django-heroku parent=None
2022-07-19 17:03:30 [info     ] init johnnydist                [johnnydep.lib] dist=dj-database-url>=0.5.0 parent=django-heroku
2022-07-19 17:03:32 [info     ] init johnnydist                [johnnydep.lib] dist=django parent=django-heroku
2022-07-19 17:03:37 [info     ] init johnnydist                [johnnydep.lib] dist=psycopg2 parent=django-heroku
2022-07-19 17:03:45 [warning  ] Created temporary directory: /private/var/folders/0t/p6l6_9qd15bb9qx6bq2mrt1r0000gn/T/pip-ephem-wheel-cache-q2agslxa
....

Notes:笔记:
1.) I stopped after the first match (possibly there are more dependencies). 1.)我在第一场比赛后就停了(可能有更多的依赖)。
2.) I dont know if it is sufficient to put psycopg2-binary at the beginning of your requirements.txt, to prevent psycopg2 needed to get installed. 2.) 我不知道将psycopg2-binary放在 requirements.txt 的开头是否足以防止安装psycopg2

Deleting "django-heroku" from requirements.txt and also removing it from settings.py file solved my issue从 requirements.txt 中删除“django-heroku”并从 settings.py 文件中删除它解决了我的问题

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在dotcloud上部署django-celery示例应用程序时,为什么会出现登录提示? - Why do I get a login prompt when I deploy the django-celery example app on dotcloud? 为什么在 MacOS 中启动 Django 服务器时出现错误? - Why do I get an error when launching Django server in MacOS? 为什么我会在 Django 教程“编写第一个 Django 应用程序”的第 4 部分中收到 404 错误 - Why do I get an 404 Error in part 4 of the Django tutorial “Writing you first Django app” 为什么我想启动 django 应用程序时收到错误消息? - why do I receive an error when I want to start my django app? 为什么我尝试在 django 应用程序上迁移时总是遇到此错误 - Why do i keep encountering this error when i try to migrate on django app 当我从Django网站使用PyVirtualDisplay运行Selenium时,为什么会出现gnome权限错误? - Why do I get a gnome permissions error when I run Selenium using PyVirtualDisplay from a Django website? 出现错误 =&gt; ModuleNotFoundError: No module named 'django' 当我尝试将 django 应用程序部署到 heroku 时 - Getting Error => ModuleNotFoundError: No module named 'django' When I attempt to deploy my django app to heroku 我想在 Heroku 上部署 Django 应用程序,但出现错误 - I want to deploy a Django app on Heroku, but I got error 为什么我在运行 startapp 时收到错误“ModuleNotFoundError: No module named 'django-extensions'” - Why do I get the error "ModuleNotFoundError: No module named 'django-extensions'" when running startapp 为什么在 Django 中运行 PostgreSQL UPDATE 时出现错误“并非所有 arguments 在字符串格式化期间转换”? - Why do I get error “not all arguments converted during string formatting” when running PostgreSQL UPDATE in Django?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM