somethingSomething somethingSomething - 2 months ago 33x
Python Question

Errors when I start the Python shell, errors from a script I ran a week ago

I've been learning python and I there is a problem with my Python interactive shell on one of my systems. It runs a script on every python-interactive-mode start(without arguments). I don't know where to look for a process that does this, I've programmed a lot of small scripts on this system, and I can see what script is messing around,

When I do this:

user@Host ~/Python Scripts> python

I get:

Python 3.4.2 (default, Feb 21 2015, 22:19:02)
[GCC 4.9.2 20150212 (Red Hat 4.9.2-6)] on linux
Type "help", "copyright", "credits" or "license" for more information.
# ! / u s r / b i n / e n v p y t h o n
Failed calling sys.__interactivehook__
Traceback (most recent call last):
File "/usr/local/opt/python-3.4.2/lib/python3.4/", line 396, in register_readline
import rlcompleter
File "/usr/local/opt/python-3.4.2/lib/python3.4/", line 161, in <module>
AttributeError: 'module' object has no attribute 'set_completer'
>>> quit()

Here is the file I ran, and is run on every python start:

#!/usr/bin/env python

number = int(input("Enter a number: "))
aFile = open('')
for i in aFile:
print(aFile.readline(), end=' ')

except ValueError:
print('Not a number, please re-enter:')
number = int(input('Enter a number: '))

except IOError:
print('Cannot open file')


What is causing this and how do I fix it?


The system is Fedora 21, the file and the script that runs on start of the interactive shell are scripts that have never been edited on a Windows system.

The system has not been rebooted for 11 day's.

Here is:

~/Python Scripts> file Python script, ASCII text executable


I have a in my current working directory:

~/Python Scripts> ls | grep readline


The last part of trys to import readline and then runs the line you error on.

    import readline
except ImportError:
    # Release references early at shutdown (the readline module's
    # contents are quasi-immortal, and the completer function holds a
    # reference to globals).
    atexit.register(lambda: readline.set_completer(None))

There must be a file somewhere in your path that you are importing instead of the actual python module. If you don't have a but once had then look for a readline.pyc file.

Put a import readline;print(readline.__file__) in your interpreter and see what exactly you are importing