5

I have an account to a computing cluster that uses Scientific Linux. Of course I only have user access. I'm working with python and I need to run python scripts, so I need to import some python modules. Since I don't have root access, I installed a local python copy on my $HOME with all the required modules. When I run the scripts on my account (hosting node), they run correctly. But in order to submit jobs to the computing queues (to process on much faster machines), I need to submit a bash script that has a line that executes the scripts. The computing cluster uses SunGrid Engine. However when I submit the bash script, I get an error that the modules I installed can't be found! I can't figure out what is wrong. I hope if you can help.

1
  • 1
    BTW - this is a software development question, not a systems administration question. As such, I've voted to have this migrated to StackOverflow. Additionally, if you have questions about how to get things to run on your cluster, it would seem appropriate to, you know, ask the people that run the cluster. Commented Mar 25, 2014 at 16:11

3 Answers 3

2

You could simply call your python program from the bash script with something like: PYTHONPATH=$HOME/lib/python /path/to/my/python my_python_script

I don't know how SunGrid works, but if it uses a different user than yours, you'll need global read access to your $HOME. Or at least to the python libraries.

Sign up to request clarification or add additional context in comments.

Comments

0

First, whether or not this solution works for you depends heavily on how the cluster is set up. That said, the general solution to your problem is below. If the compute cluster has access to the same files as you do in your home directory, I see no reason why this would not work.


You need to be using a virtualenv. Install your software inside that virtualenv along with any additional python packages you need. Then in your batch bash script, provide the full path to the python interpreter within that virtualenv.

Note: to install python packages inside your virtualenv, you need to use the pip instance that is in your virtualenv, not the system pip.

Example:

$ virtualenv foo
$ cd foo
$ ./bin/pip install numpy

Then in your bash script:

/path/to/foo/bin/python /path/to/your/script.py

2 Comments

I just created a bash script that runs 'which python' and I noticed that the output was not my python copy. But when I run 'which python' on my ssh account, I get my copy.
Try doing what I recommended - you'll provide your own copy of python for the cluster to run. And seriously, just talk with the people that run the cluster. I can clearly have no idea how they have things set up, and apparently neither do you. Talking with them is going to be your quickest path to resolution.
0

Have you tried to add these in your python code:

import sys
sys.path.append("..")
from myOtherPackage import myPythonFile

This works very well for my code when I run it on Cluster and I wanted to call my "myPythonFile" from other package "myOtherPackage"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.