首页 > 解决方案 > redis.exceptions.DataError:类型无效的输入:'NoneType'。先转换为字节、字符串或数字

问题描述

我最近开始使用 Redis 和 RQ 来运行后台进程。我构建了一个 Dash 应用程序,它在 Heroku 上运行良好,并且过去也可以在本地运行。最近,我尝试再次在本地测试同一个应用程序,但我不断收到以下错误 - 尽管我使用的是 Heroku 上托管的完全相同的代码:

redis.exceptions.DataError: Invalid input of type: 'NoneType'. Convert to a byte, string or number first.

在 Ubuntu 18.04 上的 requirements.txt 和虚拟环境中,我有 redis v.3.0.1,rq 0.13.0

当我在终端上运行 redis-server 时,我看到使用了 Redis 4.0.9(这也让我感到困惑)。

我试图谷歌两天寻找解决方案无济于事。

有没有人知道可能发生了什么以及如何解决这个错误?

这是完整的相关回溯:

File "/home/tom/dashenv/pb101_models/pages/cumulative_culture.py", line 1026, in stop_or_start_update
  job = q.fetch_job(job_id)
File "/home/tom/dashenv/dash/lib/python3.6/site-packages/rq/queue.py", line 142, in fetch_job
  self.remove(job_id)
File "/home/tom/dashenv/dash/lib/python3.6/site-packages/rq/queue.py", line 186, in remove
  return self.connection.lrem(self.key, 1, job_id)
File "/home/tom/dashenv/dash/lib/python3.6/site-packages/redis/client.py", line 1580, in lrem
  return self.execute_command('LREM', name, count, value)
File "/home/tom/dashenv/dash/lib/python3.6/site-packages/redis/client.py", line 754, in execute_command
  connection.send_command(*args)
File "/home/tom/dashenv/dash/lib/python3.6/site-packages/redis/connection.py", line 619, in send_command
  self.send_packed_command(self.pack_command(*args))
File "/home/tom/dashenv/dash/lib/python3.6/site-packages/redis/connection.py", line 659, in pack_command
  for arg in imap(self.encoder.encode, args):
File "/home/tom/dashenv/dash/lib/python3.6/site-packages/redis/connection.py", line 124, in encode
  "byte, string or number first." % typename)
redis.exceptions.DataError: Invalid input of type: 'NoneType'. Convert to a byte, string or number first.

提前感谢您的任何建议/提示。

一切顺利,汤姆

标签: redisplotlyplotly-dash

解决方案


检查此链接:redis 3.0 它说 redis-py 不再接受 NoneType


推荐阅读