Force shell to use python from conda variable in SunGrid engine

早过忘川 提交于 2019-12-11 12:52:11

问题


I'm trying to execute a python file in SunGrid engine, and I'm executing it from my anaconda3 environment variable.

my code is simple:

from __future__ import print_function
import urllib3
import numpy as np

if __name__ == '__main__':
    print('Hellooo')

I'm calling it like:

qsub -V -b n -cwd -pe mp 3 playground.py

but I am getting this error:

from: can't read /var/mail/__future__
import: unable to open X server `' @ error/import.c/ImportImageCommand/358.
/var/spool/gridengine/execd/cluster-rp-02/job_scripts/22924: 3: /var/spool/gridengine/execd/cluster-rp-02/job_scripts/22924: Syntax error: word unexpected (expecting ")")

I looked online for the error and I found a solution her: Getting Python error “from: can't read /var/mail/Bio”

it proposed to add: #!/usr/bin/env python in the beginning of the python code.

I'm using anaconda3 where the destination of the used python is not the same. So, it should be: #!../anaconda3/envs/py3/bin/python

But when I add this script I get this error:

/home/master/bin/sge_mp_startup.sh: 10: exec: /var/spool/gridengine/execd/cluster-rp-01/job_scripts/22926: not found

Did I miss something?


回答1:


From the linked question:

If your script is stored in a file named script.py, you have to execute it as python script.py

So you could add ../anaconda3/envs/py3/bin/python to the command line:

qsub -V -b n -cwd -pe mp 3 ../anaconda3/envs/py3/bin/python playground.py

Or if ../anaconda3/envs/py3/bin/python is the first python executable in your path, you could simplify:

qsub -V -b n -cwd -pe mp 3 python playground.py


来源:https://stackoverflow.com/questions/56871054/force-shell-to-use-python-from-conda-variable-in-sungrid-engine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!