我试图用cron每小时运行一个python脚本。 这就是我在crontab中拥有的一切。
#!/bin/bash
for i in "$@"
do
while read column
do
arr=(${column})
if [ ${arr[4]} = $i ]
then
echo $column
fi
done < input.txt
done
但是当它试图运行说0 * * * * python /Users/jamesrusso/Documents/TorMeasure/TorMeasurementProject/getConsensus.py
时我收到错误。我在我的python脚本中包含了ImportError: No module named stem.descriptor
。有没有人知道解决这个问题的方法或需要更多信息让我知道
答案 0 :(得分:1)
您的计算机中很可能安装了多个Python版本。更改您的cron行以包含完整路径:
0 * * * * /usr/local/bin/python /Users/jamesrusso/Documents/TorMeasure/TorMeasurementProject/getConsensus.py
答案 1 :(得分:1)
您可以检查以下步骤:
Pizza
$which python
will give you location of python installed
try to include
#!/usr/bin/env python
you can give the full path of python in your cronjob
0 * * * * /usr/local/bin/python /Users/jamesrusso/Documents/TorMeasure/TorMeasurementProject/getConsensus.py