0

I'm just trying to run a basic python script by importing the script to a second python module. But when I try to run it keep getting an error that says:

"exceptions.ImportError: No module name AUTO" 

Here is my code on the second module:

import AUTO def main(): pass if __name__ == '__main__': main() AUTO.printDate() 

AUTO is another module that has one function printDate() which just prints today's date. It just keeps error-ing out.

3
  • where (on the file system) is the "AUTO" module you try to import? what its file name? what is the output of your sys.path? Commented Jun 13, 2013 at 17:16
  • AUTO is the name of another python script that I have made Commented Jun 13, 2013 at 17:18
  • then rename it AUTO.py, and make sure that the script you're calling it from is in the same directory, cf my answer. Commented Jun 13, 2013 at 17:19

1 Answer 1

2

to import another module, it shall:

  • be a file that ends with .py
  • be in python import's path:
    • anywhere in your sys.path or
    • in current directory or
    • in any directory below your current directory that has a __init__.py (but then you have to import it using import thatdirectory.mymodule)

if you don't respect those rules, your file will not be seen by python's import system.

let's suppose the code you have in your question is foo.py, you want to have foo.py and AUTO.py together in the same directory, wherever they are.

Sign up to request clarification or add additional context in comments.

2 Comments

The file does end in .py though, its saved as AUTO.py. So it must be a directory problem then? I just need to figure out a way to find out what directory to save it in...
I figured it out, for some reason it wasn't saved in the current directory, so I just had to change it, works perfect!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.