[Tutor] import calendar not working

Michael P. Reilly arcege@shore.net
Tue, 26 Oct 1999 21:52:43 -0400 (EDT)


> I can't figure out why this works:
[...]
> And this does not work?:
> 
> #!/usr/bin/python
> 
> print "Content-type: text/html" # HTML is following
> print                           # blank line, end of headers
> 
> import sys
> import calendar
> 
> print sys.path
> 
> 
> $./cal.py
> Content-type: text/html
> 
> Traceback (innermost last):
>   File "./cal.py", line 8, in ?
>     import calendar
>   File "/home/httpd/cgi-bin/calendar.py", line 15, in ?
>     import HTMLcalendar
>   File "/usr/lib/python1.5/site-packages/HTMLgen/HTMLcalendar.py", line
> 25, in ?
>     from calendar import day_name, month_name, mdays, weekday
> ImportError: cannot import name day_name
> [mike@spin cgi-bin]$ pwd
> /home/httpd/cgi-bin
> 

This is a naming problem.. You have a module in your own software that
is using the same name as a standard module "calendar".  There can only
be one module loaded with any given name.  Either do not rely on the
standard module being loadable or rename your local module to something
other than "calendar".

Hope that helps.
  -Arcege

-- 
------------------------------------------------------------------------
| Michael P. Reilly, Release Engineer | Email: arcege@shore.net        |
| Salem, Mass. USA  01970             |                                |
------------------------------------------------------------------------