-1

Intro
I am running a python script on an cluster. I run everything in virtualenv and in the code I am importing two functions from the same module (written in SC_module.py):

ex. SC_module.py

def funA():

def funB(): 

In the script script.py I have the following import

from SC_module import funA,funB

when I run the code on the HPC I get import error funB cannot be found. If I type

from SC_module import funA

everything works fine. If I run python3 from the command line and run

from SC_module import funA,funB

everything works and fun(B) is imported.

Question
The only difference between funA() and funB() is that have been coded in two different days.
NB: If I add an new function to the module it will not be loaded when starting the process but will be imported if I will use the terminal. Is there something I miss in the loading of the module in the cluster?

Thanks

s1mc0d3
  • 523
  • 2
  • 15
  • Is your cluster long-running? Because if so, you'll have to re-import your module, which is kind of a pain. – Wayne Werner Aug 03 '16 at 14:34
  • "The only difference between funA() and funB() is that have been coded in two different days." <-- That sounds like your answer. Apparently the version of `SC_module` on the server does not have `funB`, while your local copy does. – Two-Bit Alchemist Aug 03 '16 at 14:35
  • @Two-BitAlchemist The error happens also when I completely remove the code and install a new version (with both fun) and re-start all the processes. – s1mc0d3 Aug 03 '16 at 14:37
  • @WayneWerner the process will be running for a long time but I have also been testing using the interactive mode or running mock processes for short time. – s1mc0d3 Aug 03 '16 at 14:38
  • What happens if you `import SC_module` and access the functions from there? – Rolf of Saxony Aug 03 '16 at 15:51
  • Questions seeking debugging help ("why isn't this code working?") ***MUST include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself.*** Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example. – Bakuriu Aug 03 '16 at 16:16
  • 1
    Check for circular imports. – user2357112 Aug 03 '16 at 16:22
  • @user2357112 I was a problem with a circular input that somehow was masking the function I needed to load. – s1mc0d3 Aug 04 '16 at 08:13

2 Answers2

0

Remove file: SC_module.pyc, and try run it again.

Joey.Chang
  • 164
  • 2
  • 14
0

I suggest that you print out your import path list and check that they match what you think they are, in both environments:

>>> import sys
>>> for d in sys.path:
...  print d

Plus:

import SC_module
print dir(SC_module)

to see what functions are in the imported module.
There must be a mismatch somewhere!

Rolf of Saxony
  • 21,661
  • 5
  • 39
  • 60