Traceback (most recent call last): PROBLEM

Peter Otten __peter__ at web.de
Fri Oct 12 09:38:56 EDT 2007


smarras wrote:

> Hello everyone, I keep obtaining an error message whenever I execute some
> very simple routines; the error that follows says that I am calling
> certain functions that, in reality, I am not calling from any of the
> routines that I wrote:
> 
> error:
> 
>> python fwrite_mat.py
> 
>   0, 0, 0, 0 ,  0, 1, 2, 3 ,  0, 2, 4, 6
> Traceback (most recent call last):
>   File "fwrite_mat.py", line 7, in <module>
>     from xlrd import *
>   File
> "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/xlrd/__init__.py",
> line 256, in <module>
>     from timemachine import *
>   File
> "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/xlrd/timemachine.py",
> line 21, in <module>
>     from array import array as array_array
> ImportError: cannot import name array
> 
> In these lines that I pasted, for example the "array-looking" string has
> nothing to do with my function, nor the import name "timemachine" or the
> import name "array".
> 
> Can anyone help me understand why python is looking such libraries, and
> why it keeps in memory an array that I am not using?
> 
> Here also the simple routine I wrote:
> 
> import os, sys
> import xlrd

"import xlrd" triggers the execution of the file .../xlrd/__init__.py
containing the statement "from timemachine import *" which in turn causes
.../xlrd/timemachine.py to execute. The latter file contains "from array
import array as array_array", so yes you are using "array" though
indirectly -- or you would if the import didn't fail.

The cause of the failure is probably a script named "array.py" that you
have written and put in the same folder as fwrite_mat.py. Rename
your array.py, remove the corresponding array.pyc, and the error should go
away.

Peter



More information about the Python-list mailing list