Traceback (most recent call last): PROBLEM

S

smarras

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
from numpy import *
from Numeric import *
from matplotlib import *

book = xlrd.open_workbook("/Users/simone/Desktop/prova.xls")
print "The number of worksheets is", book.nsheets
print "Worksheet name(s):", book.sheet_names()
sh = book.sheet_by_index(0)
print sh.name, sh.nrows, sh.ncols
for i in range(sh.nrows):
for j in range(sh.ncols):
print sh.row(i)
print sh.cell_value(i, j)
 
P

Peter Otten

smarras said:
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:


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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,120
Latest member
ShelaWalli
Top