gpt4 book ai didi

crontab shell时python运行redis错误

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

我在我的文件夹中安装了 redis-2.7.1,然后运行我的 python 代码,它成功了。

COMMON_MODEL_DIR="/data/aa/redis-2.7.1"
sys.path.append(COMMON_MODEL_DIR)
import redis

当我设置 crontab 时,

*/10 1-23 * * * (cd /data3/aa/; python step.py 2 >> /data3/aa/2.log 2>&1)

但是没用它会报告

Traceback (most recent call last):
File "step.py", line 11, in ?
import redis
File "/data/aa/redis-2.7.1/redis/__init__.py", line 1, in ?
from redis.client import Redis, StrictRedis
File "/data/aa/redis-2.7.1/redis/client.py", line 157
response = [nativestr(i) if i is not None else None for i in response]
^
SyntaxError: invalid syntax

我将如何修复它?

最佳答案

很明显,您的 cron 作业在其下运行的用户帐户正在使用不支持三元表达式的另一个(相当旧的)Python 版本。找出您正在使用的 Python 并在您的 crontab 中传递完整路径。

关于crontab shell时python运行redis错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24779170/

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