January 21st, 2013, 03:32 PM
Import module problem
I'm trying to import a module that contains some information. The file is called config and the code to include it is:
The file IS in that path, but when I start the program it gives me a "No such module" error.
January 21st, 2013, 03:46 PM
Originally Posted by ShadowCore
I am not sure but I think you are trying to import sys module, then add a path to the sys.path section.
When I print my sys.path, it returns:
['C:\\Python26\\Lib\\idlelib', 'C:\\WINDOWS\\system32\\python26.zip', 'C:\\Python26\\DLLs', 'C:\\Python26\\lib', 'C:\\Python26\\lib\\plat-win', 'C:\\Python26\\lib\\lib-tk', 'C:\\Python26', 'C:\\Python26\\lib\\site-packages']
These are all the folders it will look for a module. According to Python's Documentation:
Sooo I am assuming what you want to do is:
I am not sure but I think you will need the full directory for this to work. Also not sure if this WILL work. The reason you're having problems importing a module that's undefined is because the path of that module isn't in sys.path.
January 21st, 2013, 04:36 PM
I actually got it working the same minute that you replied to me. I first had to rename the file from config to config.py and then just add "from config import *" and it worked! But thank you for the fast reply