首页 > 解决方案 > Django到heroku部署问题

问题描述

在尝试部署我的 django 项目时,我遇到了一个奇怪的错误:

有一个我没有使用并卸载的依赖项,它仍在requirements.txt构建期间尝试加载。

从那以后,我卸载了所有依赖项,将其从requirements.txt、 runmakemigrations和中删除migrate,但它仍然尝试加载它,这会使部署崩溃。

PyGObject是依赖。

工作流程:Procfile -web: gunicorn solarsystem.wsgi 运行 -pip3 freeze > requirements.txt 卸载后不再显示依赖项。

但是在构建过程中:

 Collecting PyGObject
remote:          Downloading PyGObject-3.42.0.tar.gz (716 kB)
remote:          Installing build dependencies: started
remote:          Installing build dependencies: finished with status 'done'
remote:          Getting requirements to build wheel: started
remote:          Getting requirements to build wheel: finished with status 'done'
remote:            Preparing wheel metadata: started
remote:            Preparing wheel metadata: finished with status 'done'
...
 ERROR: Failed building wheel for PyGObject
...
 ERROR: Could not build wheels for PyGObject which use PEP 517 and cannot be installed directly

这是我的requirements.txt

asgiref==3.3.4
autopep8==1.5.7
boto3==1.17.108
botocore==1.20.108
click==8.0.1
cm-rgb==0.3.6
cycler==0.10.0
dj-database-url==0.5.0
Django==3.2.3
django-appconf==1.0.4
django-compressor==2.2
django-heroku==0.3.1
django-libsass==0.9
django-material==1.9.0
django-materializecss-form==1.1.17
django-on-heroku==1.1.2
django-sass-processor==1.0.1
gunicorn==20.1.0
hidapi==0.10.1
Jinja2==3.0.1
jmespath==0.10.0
kiwisolver==1.3.1
libsass==0.21.0
MarkupSafe==2.0.1
matplotlib==3.4.3
mpld3==0.5.5
numpy==1.21.2
Pillow==8.3.1
psutil==5.8.0
psycopg2==2.9.1
psycopg2-binary==2.9.1
pycairo==1.20.1
pycodestyle==2.7.0
pyparsing==2.4.7
python-dateutil==2.8.1
pytz==2021.1
PyYAML==5.4.1
rcssmin==1.0.6
rjsmin==1.0.12
s3transfer==0.4.2
six==1.16.0
sqlparse==0.4.1
toml==0.10.2
urllib3==1.26.6
whitenoise==5.3.0

requirements.txt我已经尝试了和配置的多种变体Procfile,查看了我的源代码以查找PyGObjector的任何导入gi,但没有。我还搜索了PyGObject文档和其他堆栈溢出资源,但均未成功。

重申一下,我想以某种其他方式完全删除它,或者以某种方式在某处为该依赖项添加一个忽略语句,以便我可以成功部署。

标签: pythondjangoherokudependenciespygobject

解决方案


matplotlib 使用 PyGobject,这就是为什么它在安装 requirements.txt 文件时尝试安装 PyGobject, https: //pygobject.readthedocs.io/en/latest/ 尝试使用以下命令。它可能会解决安装 PyGobject 的问题

python3 -m pip install --no-use-pep517  cm-rgb

或者

sudo pacman -S python cairo pkgconf gobject-introspection gtk3 
pip3 install pycairo to build and install Pycairo
pip3 install PyGObject to build and install PyGObject

推荐阅读