scipy code runs in empty directory, not another

Terry Reedy tjreedy at
Sat Nov 13 20:00:39 CET 2010

On 11/13/2010 11:41 AM, Dave Angel wrote:
> On 2:59 PM, Beliavsky wrote:
>> After installing numpy, scipy, and matplotlib for python 2.6 and
>> running the code from
>> (stored as in a directory with other python codes, I got
>> the error messages
>> C:\python\code\mycode>python
>> Traceback (most recent call last):
>> File "", line 3, in<module>

Learn to read tracebacks. They are your debugging friend.

>> from pylab import *

xoptimize imports pylab

>> File "c:\python26\lib\site-packages\", line 1, in<module>
>> from matplotlib.pylab import *

pylab imports matplotlib

>> File "c:\python26\lib\site-packages\matplotlib\", line
>> 133, in<module>
>> import sys, os, tempfile

matplotlib imports tempfile (to get a plot destination)

>> File "c:\python26\lib\", line 34, in<module>
>> from random import Random as _Random

tempfile import random (to make a 'random' tempfile name)

>> File "C:\python\code\mycode\", line 1, in<module>

Look carefully at the above line. It should have been:
File "C:\python26\lib\ ...

Ignore the remaining error cascade.

>> When I create a new directory, copy there, and run, the
>> program works. Can someone explain why other files are "interfering"
>> in the first case? Thanks.
> You have a file in your code directory, which is shadowing the
> system random library.

As you can see in the traceback.

Terry Jan Reedy

More information about the Python-list mailing list