AC上获取crontab以运行anaconda安装的python

AC上获取crontab以运行anaconda安装的python

本文介绍了在MAC上获取crontab以运行anaconda安装的python脚本(未找到模块)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为通过蟒蛇安装的用python编写的脚本设置crontab.简单的.py运行(它只加载一个演示模块),并且可以在终端中使用python a.py运行.问题是让crontab成为python和导入模块的路径.

I am trying to set up crontab for a script written in python which is intalled via Anaconda. The simple .py runs (it just loads a module for a demo) and can be run in terminal with python a.py .The problem is getting crontab the path for python and imported modules.

我一直在尝试将PATH和PYTHONPATh设置为python目录以及大熊猫所在的位置.我认为这是一个环境问题,但不知道那是什么意思.有什么想法吗?

I have been trying to set the PATH and PYTHONPATh to the python directory and also where pandas is located. I think this is a env issue but have no idea what that means. Any ideas?

crontab是:

SHELL=/bin/sh
PYTHONPATH=/Users/Esel/anaconda3/bin/python
* * * * *  cd /Users/Esel/Documents/x/y/z && python a.py

python(测试)脚本:

The python (test) script:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Jul 18 21:36:34 2019

@author: Esel
"""

import pandas

print('hello kitty')
# This is a test

Crontab邮寄以下声明:

Crontab mails the following statement:

回溯(最近通话最近):在第3行中输入文件"a.py"进口大熊猫ImportError:没有名为pandas的模块

Traceback (most recent call last): File "a.py", line 3, in import pandasImportError: No module named pandas

推荐答案

我想到了roadowl(thanx)的一些想法和另一个SOverflow问题(54564187),我想我已经开始运行它了.

With some ideas from a roadowl (thanx) and another SOverflow question (54564187) I think I got it running.

SHELL=/bin/sh
PATH=$PATH/Users/Esel/anaconda3/bin:/Users/Esel/anaconda3/condabin:/Applications/anaconda3/bin:/Applications/anaconda3/bin:/Users/Esel/anaconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
* * * * *  cd /Users/Esel/Documents/x/y/z && python a.py

路径来自

echo $PATH

这篇关于在MAC上获取crontab以运行anaconda安装的python脚本(未找到模块)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 00:49