By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,497 Members | 1,295 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,497 IT Pros & Developers. It's quick & easy.

Error in random module, bad installation?

P: n/a
I'm a linux user and I just upgraded from 2.1 to 2.5 and changed the
location of a number of libraries and tools.

So far I've tracked most errors, but this one has me scratching my
head :

$ which python
/usr/local/bin/python
$ echo $PYTHONPATH
/usr/local/bin/python
$ python
Python 2.5.1 (r251:54863, Sep 5 2007, 09:48:37)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>import random
Unexpected error: <type 'exceptions.TypeError'>
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "random.py", line 10, in <module>
x = random.random()
TypeError: 'module' object is not callable
>>>
$ find /usr/local/ -name random.py
../lib/python2.5/random.py
../lib/python2.3/random.py

Do I need to clobber 2.3? ( If so, why???)

TIA

-- Andrew

Sep 12 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Wed, 2007-09-12 at 15:13 -0700, Andrew F wrote:
>import random
Unexpected error: <type 'exceptions.TypeError'>
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "random.py", line 10, in <module>
x = random.random()
TypeError: 'module' object is not callable
You have a file called random.py in your current directory. It's
shadowing the random module from the library.

HTH,

--
Carsten Haese
http://informixdb.sourceforge.net
Sep 12 '07 #2

P: n/a
Andrew F <an********@nymag.comwrote:
>I'm a linux user and I just upgraded from 2.1 to 2.5 and changed the
location of a number of libraries and tools.

So far I've tracked most errors, but this one has me scratching my
head :

$ which python
/usr/local/bin/python
$ echo $PYTHONPATH
/usr/local/bin/python
PYTHONPATH is supposed to point to the directory containing modules, NOT
the directory containing the executable. It should be /lib/python2.5.

However, Carsten had the real cause for your immediate problem.
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Sep 13 '07 #3

P: n/a
On Sep 13, 12:57 am, Tim Roberts <t...@probo.comwrote:
Andrew F <andrew....@nymag.comwrote:
I'm a linux user and I just upgraded from 2.1 to 2.5 and changed the
location of a number of libraries and tools.
So far I've tracked most errors, but this one has me scratching my
head :
$ which python
/usr/local/bin/python
$ echo $PYTHONPATH
/usr/local/bin/python

PYTHONPATH is supposed to point to the directory containing modules, NOT
the directory containing the executable. It should be /lib/python2.5.
Thank you both -- it was a combination of the problems.

Sep 13 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.