首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Heroku: ModuleNotFoundError :没有名为“请求”的模块

Heroku: ModuleNotFoundError :没有名为“请求”的模块
EN

Stack Overflow用户
提问于 2019-03-21 01:56:59
回答 1查看 5.8K关注 0票数 2

我正在尝试将Django程序部署到Heroku。应用程序在我的本地机器上成功运行,它使用了Anaconda和Python3.5。我不能把它推到Heroku。听从命令

代码语言:javascript
复制
>git push heroku master

remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Python app detected
remote:  !     Python has released a security update! Please consider upgrading to python-3.6.8
remote:        Learn More: https://devcenter.heroku.com/articles/python-runtimes
remote: -----> Installing python-3.6.2
remote: -----> Installing pip
remote: -----> Installing dependencies with Pipenv 2018.5.18…
remote:        Installing dependencies from Pipfile.lock (958efe)…
remote: -----> Installing SQLite3
remote: -----> $ python manage.py collectstatic --noinput
remote:        Traceback (most recent call last):
remote:          File "manage.py", line 15, in <module>
remote:            execute_from_command_line(sys.argv)
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
remote:            utility.execute()
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, in execute
remote:            django.setup()
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
remote:            apps.populate(settings.INSTALLED_APPS)
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/registry.py", line 89, in populate
remote:            app_config = AppConfig.create(entry)
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/config.py", line 90, in create
remote:            module = import_module(entry)
remote:          File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
remote:            return _bootstrap._gcd_import(name[level:], package, level)
remote:          File "<frozen importlib._bootstrap>", line 978, in _gcd_import
remote:          File "<frozen importlib._bootstrap>", line 961, in _find_and_load
remote:          File "<frozen importlib._bootstrap>", line 948, in _find_and_load_unlocked
remote:        ModuleNotFoundError: No module named 'requests'
remote: 
remote:  !     Error while running '$ python manage.py collectstatic --noinput'.
remote:        See traceback above for details.
remote: 
remote:        You may need to update application code to resolve this error.
remote:        Or, you can disable collectstatic for this application:
remote: 
remote:           $ heroku config:set DISABLE_COLLECTSTATIC=1
remote: 
remote:        https://devcenter.heroku.com/articles/django-assets
remote:  !     Push rejected, failed to compile Python app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !   Push rejected to [redacted].

我不知道为什么我不能让requests模块安装在Heroku中的pip。它在我的requirements.txt文件中:

代码语言:javascript
复制
Django==2.1.7
dj-database-url==0.5.0
dj-static==0.0.6
gunicorn==19.9.0
Unipath==1.1
python-decouple==3.1
Pillow==3.3.0
Markdown==3.0.1
bleach==3.1.0
psycopg2==2.7.7
whitenoise==4.1.2
requests==2.21.0
requests-oauthlib==1.0.0
EN

回答 1

Stack Overflow用户

发布于 2019-03-21 02:33:04

Heroku构建的输出显示,除了PipfilePipfile.lock之外,还有一个requirements.txt

您需要在使用pip (使用requirements.txt)还是Pipenv (使用PipfilePipfile.lock)之间进行选择。如果所有三个文件都存在,Heroku将使用Pipenv安装,而忽略您的requirements.txt文件。

任一

  • 将您的需求移动到您的Pipfile并在本地运行Pipenv以安装它们并更新您的Pipfile.lock、删除您的requirements.txt、提交和推送(使用Pipenv),或
  • 删除PipfilePipfile.lock,在本地使用pip (或pip-tools或类似的),提交和推送(使用pip)。
票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55272714

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档