Python: using downloaded modules

I am new to Python and mostly used my own code. But so now I downloaded a package that I need for some problem I have.

Example structure:

root\
    externals\
        __init__.py
        cowfactory\
            __init__.py
            cow.py
            milk.py

    kittens.py

Now the cowfactory's __init__.py does from cowfactory import cow. This gives an import error.

I could fix it and change the import statement to from externals.cowfactory import cow but something tells me that there is an easier way since it's not very practical.

An other fix could be to put the cowfactory package in the root of my project but that's not very tidy either.

I think I have to do something with the __init__.py file in the externals directory but I am not sure what.

11
задан Pickels 4 September 2010 в 07:36
поделиться