PDA

View Full Version : python not importing file in terminal.



upupz
September 22nd, 2011, 10:40 PM
I am trying to use the import command as such:

import hello world

this is the output, plus an ls to show the file in in the directory.


upupz@upupz-laptop:~/Documents/Python/Basics$ ls
bbb.txt hello world.py input output.py
upupz@upupz-laptop:~/Documents/Python/Basics$ python3.1
Python 3.1.2 (r312:79147, Sep 27 2010, 09:45:41)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import hello world
File "<stdin>", line 1
import hello world
^


I am sure this some silly error on my part but for the life of me I can't find it. this is the text in the file.


"""
coder : upupz
aim : text output
user base : upupz
"""



print("hello world!")


Thanks

ubudog
September 23rd, 2011, 12:59 AM
Moved to Programming Talk. Hopefully you get more answers here.

thatguruguy
September 23rd, 2011, 01:21 AM
Python doesn't like the space in the module name. Rename the script to helloworld.py and then try to import it.

drmrgd
September 23rd, 2011, 12:54 PM
Yeah, it's the space messing you up there. It's best to just avoid putting spaces in file names, as they make working with things much more difficult. Avoid spaces, and be careful with capital letters :D