Django显示错误,例如“导入错误没有名为redis的模块”

时间:2018-09-27 06:47:00

标签: django python-3.x python-2.7

#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "queuearoo.settings")

    from django.core.management import execute_from_command_line

    execute_from_command_line(sys.argv)

我正在使用puTTY从远程服务器进行访问,并得到如下错误

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/devbase/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "/home/devbase/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 308, in execute
    settings.INSTALLED_APPS
  File "/home/devbase/env/local/lib/python2.7/site-packages/django/conf/__init__.py", line 56, in __getattr__
    self._setup(name)
  File "/home/devbase/env/local/lib/python2.7/site-packages/django/conf/__init__.py", line 41, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/devbase/env/local/lib/python2.7/site-packages/django/conf/__init__.py", line 110, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/devbase/devbase/queuearoo/queuearoo/settings.py", line 2, in <module>
    import os,redis
ImportError: No module named redis

1 个答案:

答案 0 :(得分:0)

您只需要使用以下命令安装redis

pip install redis

还请注意,您正在使用虚拟环境,因此需要先将其激活:

source /home/devbase/env/local/bin/activate