没有名为'requests'的模块- Django部署到Heroku上

bq8i3lrv  于 2022-11-24  发布在  Go
关注(0)|答案(2)|浏览(110)

将一些新代码部署到Heroku上的应用程序中,现在显示以下消息:No module named 'requests' .应用程序之前运行正常,所以这一定是我改的。
在展示代码之前,我注意到两件事:我的过程文件和需求文件在Visual Studio中是不可见的(可以在Sublime文本编辑器中看到)。2最近才开始使用VS,现在才注意到。3不确定这在这里是否重要。
我不确定错误是从哪里来的,所以我在下面留下了traceback、Procfile和requirements.txt文件。
如果需要添加其他内容,请告诉我。

回溯

$ git push heroku master
Enumerating objects: 111, done.
Counting objects: 100% (111/111), done.
Delta compression using up to 4 threads
Compressing objects: 100% (80/80), done.
Writing objects: 100% (81/81), 129.38 KiB | 2.59 MiB/s, done.
Total 81 (delta 23), reused 1 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: heroku/python
remote: -----> Python app detected
remote: -----> No Python version was specified. Using the same version as the last build: python-3.10.5
remote:        To use a different version, see: https://devcenter.heroku.com/articles/python-runtimes
remote:  !
remote:  !     A Python security update is available! Upgrade as soon as possible to: python-3.10.7
remote:  !     See: https://devcenter.heroku.com/articles/python-runtimes
remote:  !
remote: -----> No change in requirements detected, installing from cache
remote: -----> Using cached install of python-3.10.5
remote: -----> Installing pip 22.2.2, setuptools 63.4.3 and wheel 0.37.1
remote: -----> Installing SQLite3
remote: -----> Installing requirements with pip
remote: -----> $ python manage.py collectstatic --noinput
remote:        Found another file with the destination path 'Logo.png'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
remote:        139 static files copied to '/tmp/build_42cf0f4b/staticfiles', 5 unmodified, 378 post-processed.
remote:
remote: -----> Discovering process types
remote:        Procfile declares types -> web
remote:
remote: -----> Compressing...
remote:        Done: 92.2M
remote: -----> Launching...
remote:        Released v53
remote:        App deployed to Heroku

过程文件

web: gunicorn mysite.wsgi

需求.txt

asgiref==3.5.2
click==8.1.3
colorama==0.4.5
defusedxml==0.7.1
diff-match-patch==20200713
dj-database-url==0.5.0
Django==4.0.6
django-crispy-forms==1.14.0
django-heroku==0.3.1
django-import-export==2.8.0
et-xmlfile==1.1.0
Flask==2.1.3
gunicorn==20.1.0
itsdangerous==2.1.2
Jinja2==3.1.2
MarkupPy==1.14
MarkupSafe==2.1.1
numpy==1.23.1
odfpy==1.4.1
openpyxl==3.0.10
pandas==1.4.3
Pillow==9.2.0
psycopg2==2.9.3
pymongo==4.1.1
python-dateutil==2.8.2
python-decouple==3.6
pytz==2022.1
PyYAML==6.0
six==1.16.0
sqlparse==0.4.2
tablib==3.2.1
tzdata==2022.1
Werkzeug==2.1.2
whitenoise==6.2.0
xlrd==2.0.1
xlwt==1.3.0
xienkqul

xienkqul1#

您必须在Requirements.txt中添加requests,如下所示:

requests==2.28.1
k4emjkb1

k4emjkb12#

通过运行以下命令安装request

pip install requests

然后更新您的Requirements.txt只需运行

pip freeze > Requirements.txt

这将添加您在项目中使用过的所有库,包括新安装的。

相关问题