473,508 Members | 2,382 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error in random module, bad installation?

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
3 2410
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
1946
by: Robert Stearns | last post by:
Note: deliberately xposted to the two newsgroups which seem applicable, after reading several hundred messages from various php groups. Randomly my application gets the message: Warning:...
28
3653
by: Paul Rubin | last post by:
http://www.nightsong.com/phr/python/sharandom.c This is intended to be less predicable/have fewer correlations than the default Mersenne Twister or Wichmann-Hill generators. Comments are...
3
6358
by: Rob B | last post by:
Hello, I am just starting to learn Python and was writing a simple script on my machine (Mac OS X 10.3.4), but I can't seem to import the random module: #!/usr/bin/env python import random
0
972
by: charliek | last post by:
I have mod_python 2.7.10 running with python 2.3.4 and am getting an odd error. The error is happening on the production machine, and not on my development machine. I am using the publisher...
10
1668
by: Glenn Wilson | last post by:
I have a quick Question and I Hope some one can help or at least explain. What is happening is that I am trying to use random numbers in an application, as per the sample test code below. When I...
14
9374
by: DataSmash | last post by:
Hi, When I import the random module at the python interpreter, it works fine: >>> import random >>> x = random.randint(1,55) >>> print x 14 >>> BUT, when I put the same code in a python...
39
2429
by: Alan Isaac | last post by:
This may seem very strange, but it is true. If I delete a .pyc file, my program executes with a different state! In a single directory I have module1 and module2. module1 imports random and...
2
1746
by: prakashwadhwani | last post by:
I have a small app which has been working fine for about 1 year now on WinXp with Office 2003. All of a sudden without any changes being made to it, the app is giving an error on startup ... here's...
5
13459
by: =?GB2312?B?17/HvyBaaHVvLCBRaWFuZw==?= | last post by:
Hi, I would like to have someone comments on what's the best practice defining error codes in C. Here's what I think: solution A: using enum pros: type safe. better for debug (some debugger...
0
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7115
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7321
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7036
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7489
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5047
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.