安装Redis时缺少Redis库

时间:2018-12-14 14:02:40

标签: python redis pycharm celery windows-subsystem-for-linux

我已经安装了redis和celery python库。我已经安装并正在运行Redis服务器。使用bash,我可以运行pythonimport redis而不会出错。我安装了python-celery-common。我正在使用PyCharm和WSL。由于某些原因,当我创建task.py并尝试在bash中运行celery -A tasks worker --loglevel=info 时,我得到以下堆栈跟踪信息(请注意,当我运行python 2.7时,芹菜路径中的python3-我觉得这很重要,但不知道如何或如何更改):

Traceback (most recent call last):
  File "/usr/bin/celery", line 26, in <module>
    load_entry_point("celery", "console_scripts", "celery")()
  File "/usr/lib/python3/dist-packages/celery/__main__.py", line 14, in main
    _main()
  File "/usr/lib/python3/dist-packages/celery/bin/celery.py", line 326, in main
    cmd.execute_from_commandline(argv)
  File "/usr/lib/python3/dist-packages/celery/bin/celery.py", line 488, in execute_from_commandline
    super(CeleryCommand, self).execute_from_commandline(argv)))
  File "/usr/lib/python3/dist-packages/celery/bin/base.py", line 281, in execute_from_commandline
    return self.handle_argv(self.prog_name, argv[1:])
  File "/usr/lib/python3/dist-packages/celery/bin/celery.py", line 480, in handle_argv
    return self.execute(command, argv)
  File "/usr/lib/python3/dist-packages/celery/bin/celery.py", line 412, in execute
    ).run_from_argv(self.prog_name, argv[1:], command=argv[0])
  File "/usr/lib/python3/dist-packages/celery/bin/worker.py", line 221, in run_from_argv
    return self(*args, **options)
  File "/usr/lib/python3/dist-packages/celery/bin/base.py", line 244, in __call__
    ret = self.run(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/celery/bin/worker.py", line 255, in run
    **kwargs)
  File "/usr/lib/python3/dist-packages/celery/worker/worker.py", line 99, in __init__
    self.setup_instance(**self.prepare_args(**kwargs))
  File "/usr/lib/python3/dist-packages/celery/worker/worker.py", line 122, in setup_instance
    self.should_use_eventloop() if use_eventloop is None
  File "/usr/lib/python3/dist-packages/celery/worker/worker.py", line 241, in should_use_eventloop
    self._conninfo.transport.implements.async and
  File "/usr/lib/python3/dist-packages/kombu/connection.py", line 832, in transport
    self._transport = self.create_transport()
  File "/usr/lib/python3/dist-packages/kombu/connection.py", line 576, in create_transport
    return self.get_transport_cls()(client=self)
  File "/usr/lib/python3/dist-packages/kombu/transport/redis.py", line 1009, in __init__
    raise ImportError('Missing redis library (pip install redis)')
ImportError: Missing redis library (pip install redis)

我运行python时bash的输出:

Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.

pip freeze的输出

 amqp==2.3.2
asn1crypto==0.24.0
billiard==3.5.0.5
celery==4.2.1
cryptography==2.1.4
Django==1.11.11
djangorestframework==3.9.0
enum34==1.1.6
idna==2.6
ipaddress==1.0.17
keyring==10.6.0
keyrings.alt==3.0
kombu==4.2.2
psycopg2==2.7.4
pycrypto==2.6.1
pygobject==3.26.1
pytz==2018.7
pyxdg==0.25
redis==3.0.1
SecretStorage==2.3.1
six==1.11.0
sqlparse==0.2.4
vine==1.1.4

1 个答案:

答案 0 :(得分:0)

更合理的问题是在pycharm中设置解释器时,您为其指定了错误的路径,将其设置为/ usr / bin / python3而不是python2的路径