• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

Reset Python

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.

whiterabbit391

Registered
Joined
Aug 2, 2014
Is there a way to reset python. Or . Perhaps. __Re-install it?

I say this because my python is acting strange . There are certain basic commands that it is reporting as error.

Just trying to play around with randint and some variables,
and it doesn't recognize randint

Traceback (most recent call last):
file "dice.py", line 1, in <module>
import random
file "/home/wrabbit/random.py", line 4, in <module>
password = "".join(choice(characters) for x in range(randint(8,16)))
NameError: name 'randint' is not defined

___________________________________
so on and so on. It's all bugged out.

can I just reset it or re-install it or debug it?
Is there a way?

------------------------------------------
Code:
import random
for x in range (1,11):
	throw_1 = random.randint(1,6)
	throw_2 = random.randint(1,6)
	total = throw_1 + throw_2
	print (total)
	if total == 7:
		print ('Seven Thrown!')
	if total == 11:
		print ('Eleven Thrown!')
	if throw_1 == throw_2:
		print ('Double Thrown!')
 
What is /home/wrabbit/random.py?
When you import random, it should be using the random.py that comes with python.. it looks like you've got some other version of random.py in your working directory that the interpreter is attempting to use, which has the syntax error. The error isn't in your dice.py code, it's in /home/wrabbit/random.py.

Remove or rename /home/wrabbit/random.py to something else and you'll be good, I imagine.
 
that was just me blocking out my computer name ...... like it matters.

Python is just bugged out on something, wish I knew how to reinstall it or debug it.

Here, let me take a screenshot .

Even if I simply type in
>>>python
>>>from random import randint

It does this

Screenshot from 2015-04-20 03:38:39.png
 
Still, the issue is in random.py. This code:
Code:
password = "".join(choice(characters) for x in range(randint(8,16)))
shouldn't be in random.py.

Run this:
Code:
find / -name random.py -exec ls -l {} \; 2>/dev/null

and paste the results.

If you want to completely rebuild python, you can either download the rpm and unpack it with the --force command. Or you can uninstall the package (via apt-get or yum depending on the distro you're on), and then re-install.
 
What version of linux are you on? You can always do a reinstall.

I wonder if random.py is corrupted

Here is the md5sum of mine

Code:
7c427c5c4e13aafaf082a9686e6f94ea  /usr/lib/python2.7/random.py
 
Back