gpt4 book ai didi

python - 安装redis时缺少redis库

转载 作者:可可西里 更新时间:2023-11-01 11:24:01 25 4
gpt4 key购买 nike

我安装了 redis 和 celery python 库。我已经安装并运行了 redis 服务器。使用 bash 我可以运行 pythonimport redis 而不会出错。我安装了 python-celery-common 。我正在使用 PyCharm 和 WSL。出于某种原因,当我创建 tasks.py 并尝试运行 celery -A tasks worker --loglevel=info
在 bash 中我得到以下堆栈跟踪(注意当我运行 python 2.7 时 celery 路径中的 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

最佳答案

更合理的问题是,在 pycharm 中,当你设置解释器时,你给了它错误的路径。你将它设置为/usr/bin/python3 而不是 python2 的路径

关于python - 安装redis时缺少redis库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53781227/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com