I have a directory structure :
../POC/mud/ client/ common/ server/
and i am trying to use the following imports :
from mud.server import config from mud.common.lib import util
but when i try to import config , i get an error:
Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from mud.server import config Traceback (most recent call last): File "", line 1, in ImportError: No module named mud.server >>> from mud.common.lib import util Traceback (most recent call last): File "", line 1, in ImportError: No module named mud.common.lib >>>
Do i need to be in a certain location for imports to work, or the modules need to be compiled on the OS ? these "mud" modules are just a collection of python .py files
First you have to have __init__.py
file in the mud and sub-folders, the file can be empty though. Take a look at the Python tutorial in the packages section: http://docs.python.org/tutorial/modules.html#packages
In addtion you need to be in the POC folder for the import statements to work or you set the PYTHONPATH env var accordingly or update sys.path dynamically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With