0

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")
Dirty_Fox
  • 1,611
  • 4
  • 20
  • 24
  • you have to download and install this package datayhton and then you can import it. – midori Jan 08 '15 at 04:26
  • how would I dl and install something I wrote ? – Dirty_Fox Jan 08 '15 at 04:32
  • If it's not built in package you need to download and install it, you can use pip or just download it from the Internet – midori Jan 08 '15 at 04:33
  • I might miss your point here but datayhton is not a built in package but a module I ve written. Therefore I dnt really see how I coul dl it from the internet – Dirty_Fox Jan 08 '15 at 04:36
  • if it's handwritten module - link it in sys.path, but it should work if it's in the same folder as your program. – midori Jan 08 '15 at 04:40
  • It should ... unfortunately it does not look to be in teh mood. Shall I link it via the console or directly in my code ? I linked it in my code but still ... – Dirty_Fox Jan 08 '15 at 04:43
  • Can you show what you're appending to `sys.path`? Or even better, can you update the code sample above to show that you're doing the `sys.path.append`? – zehnpaard Jan 08 '15 at 04:44
  • 3
    You spell `dataython` in some places but `datayhton` in the code, swapping the `h` and `t`. – Alex Martelli Jan 08 '15 at 04:59
  • FWIW, it's generally **not** a good idea to use `from somemodule import *` in a script. See http://stackoverflow.com/questions/2386714/why-is-import-bad – PM 2Ring Jan 08 '15 at 06:34

1 Answers1

2

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 *

Dirty_Fox
  • 1,611
  • 4
  • 20
  • 24