StarCluster - Mailing List Archive

Cannot find a module

From: Ya Xue <no email>
Date: Mon, 18 Aug 2014 15:49:49 -0400


I have a script that needs to import a module and the module name is given as an input parameter. It works well on a local machine but generates "ImportError" with StarCluster. Here is a simple script that can reproduce the error:

def imp(fname):
    if fname[-3:] == '.py':
        fname = fname[:-3]
    exec('import ' + fname + ' as params')
    print params.alpha
    f = open(fname+'_alpha.txt', 'w')
    f.write('%f' % params.alpha)

If I run it on the StarCluster master, no problem:

In [1]: run

In [3]: imp('')

However, on the cluster:

In [4]: from IPython.parallel import Client

In [5]: c = Client()

In [6]: v = c[:]

In [7]: files = ['','','']

In [8]: r =, files)

In [9]: r[0]
ImportError Traceback (most recent call last)<string> in <module>()
/home/ya/Code/ in imp(fname)
      4 if fname[-3:] == '.py':
      5 fname = fname[:-3]
----> 6 exec('import ' + fname + ' as params')
      7 print params.alpha
      8 f = open(fname+'_alpha.txt', 'w')
<string> in <module>()
ImportError: No module named p1

Does anyone know how to fix it?


This email (including any attachments) may contain confidential information intended solely for acknowledged recipients. If you think you have received this information in error, please reply to the sender and delete all copies from your system. Please note that unauthorized use, disclosure, or further distribution of this information is prohibited by the sender. Note also that we may monitor email directed to or originating from our network. Thank you for your consideration and assistance. |

  • application/octet-stream attachment:
  • application/octet-stream attachment:
  • application/octet-stream attachment:
  • application/octet-stream attachment:
Received on Mon Aug 18 2014 - 15:49:53 EDT
This archive was generated by hypermail 2.3.0.


Sort all by: