Dirty_Fox
Dirty_Fox

Reputation: 1771

How to resolve "ImportError : no module named ... " in python?

Chaps I am going through what is apparently a #1 problem for python novice. I have been through some tutorials but I really can t get it works. Here is the code :

import time

from settings import *
from actif_class import * 

from get_settings import *
from dataython import *
from spreadython import * 
from tankython import *



if __name__ == "__main__": 
    t0 = time.clock()

    settings = get_settings()    
    tickers = get_data_mp(settings)
    list_spreads = get_list_spread(tickers,settings)
    list_spreads_tank = tanking(list_spreads,settings)
    spread_traitable = obtention_spreads_traitables(list_spreads_tank,settings) 

    print 'done. Timing',time.clock()-t0,'seconds'   

and here is the stack :

 ImportError: No module named datayhton

Even though the module DOES exist and is in the same folder as every other modules. It is able to see the get_settings one but not dataython. I ve tried on another machine but still got the same trouble.

I tried to go through import sys, sys.path.append but I might have done something wrong because it still doesnt work.

Any help would be much appreciated.

EDIT : still doesnt work when I write this on top of my code :

import time
import sys 
sys.path.append("/path/to/dataython")

Upvotes: 0

Views: 7287

Answers (1)

Dirty_Fox
Dirty_Fox

Reputation: 1771

Ok. I got it now. Not a no brainer so here is the amended code :

import time
import sys
sys.path.append("path/to/your/file")
import your_file 

the mistake I was doing was keep writing : from your_file import *

Upvotes: 2

Related Questions