471,357 Members | 1,077 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,357 software developers and data experts.

Traceback (most recent call last): PROBLEM

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)
Oct 12 '07 #1
1 27382
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
Oct 12 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Mark | last post: by
4 posts views Thread by Lee | last post: by
reply views Thread by smarras | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.