1

My python file is in the folder 'RealData/Python/run.py' What I need to do in run.py is to import another python file: plot_ensembles.py which is in the folder 'RealData/convolution/plot_ensembles.py'

My code returns an error:

import sys
sys.path.append( 'myname/Documents/RealData/convolution')
import plot_ensembles

ImportError: No module named 'plot_ensembles'

Probably this is a stupid mistake...

4
  • What system are you running on? Commented Jan 8, 2016 at 11:52
  • What if you do import ../../convolution/plot_ensemble ?
    – MaTh
    Commented Jan 8, 2016 at 11:58
  • @Drjnker If I run ´import ../../convolution/plot_ensembles´ it returns invalid syntax
    – Simmias
    Commented Jan 8, 2016 at 12:05
  • 1
    See Also stackoverflow.com/questions/2349991/… Commented Jan 8, 2016 at 12:07

1 Answer 1

1

You can try In the file that has the script, you want to do something like this:

import sys
sys.path.append(os.path.realpath('../convolution'))
import plot_ensembles
1
  • and then import filename ? This returns the error "No module named filename"
    – Simmias
    Commented Jan 8, 2016 at 12:06

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.