Import fails (newbie)

mhorlick mhorlick at videotron.ca
Thu Jun 17 15:04:21 EDT 2010


Hello,

I'm a newbie and I have a small problem. After invoking IDLE -->

Python 3.1.2 (r312:79149, Mar 21 2010, 00:41:52) [MSC v.1500 32 bit
(Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import os,glob
>>> os.chdir('D:/Python_Programs')
>>> print(os.getcwd())
D:\Python_Programs
>>> print(glob.glob('*.*'))
['humansize.py', 'humansize.pyc']
>>> import humansize
Traceback (most recent call last):
  File "<pyshell#5>", line 1, in <module>
    import humansize
ImportError: No module named humansize
>>>

In a DOS command window I have no problems with the program:

 Directory of D:\Python_Programs

17/06/2010  01:56 PM    <DIR>          .
17/06/2010  01:56 PM    <DIR>          ..
17/06/2010  02:53 PM             1,266 humansize.py
17/06/2010  01:56 PM             1,315 humansize.pyc
               2 File(s)          2,581 bytes
               2 Dir(s)  104,122,085,376 bytes free

D:\Python_Programs>c:\python31\python humansize.py
1.0 TB
931.3 GiB

This 'humansize.py' program I got from the book 'Dive Into Python 3'.
I don't know if you need to know the source.

Can someone explain why the 'import' fails?

Thanks,

Mike



More information about the Python-list mailing list