473,786 Members | 2,410 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.Typ eError'>
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 2427
On Wed, 2007-09-12 at 15:13 -0700, Andrew F wrote:
>import random
Unexpected error: <type 'exceptions.Typ eError'>
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********@nym ag.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.com wrote:
Andrew F <andrew....@nym ag.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
1968
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: odbc_connect(): SQL error: O*@|VA@§ÿ¿Û, SQL state ýÿÿÿ|ýÿÿÿüØ\|ýÿÿÿˆªÿ¿˜EW@Ôªÿ¿ in SQLConnect in /var/www/html/GEM/db.php on line 15
28
3707
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 appreciated.
3
6376
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
987
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 handler and am calling the index function with this code: ---------------------------------- from mod_python import apache import random
10
1695
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 run this code the random numbers that are displayed are all the same for abot 25 cycles and then randomize as normal. Can some one tell me why this is or at least tell me what I am doing wrong. Regards Glenn Module Module1
14
9407
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 script:
39
2471
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 MyClass from module2. module2 does not import random. module1 sets a seed like this::
2
1758
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 the error description: Run-time error 429 ActiveX component can't create object If I copy the same Access app onto another PC, it works fine ! No error !! I've tried it on 2 different PC's.
5
13498
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 will show the name not only the value) cons: enum can not be forward declared which makes all error codes
0
9647
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9492
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10163
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10108
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7510
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5397
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4064
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3668
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.