Skip to content Skip to sidebar Skip to footer

How To Set Configuration For Readline In Python

According to the answer to question, I installed readline for python to resolve backspace issue. If I logged in CentOS 7 as a root, I can backspace without any problems;however, if

Solution 1:

NOTE: My system is CentOS 7. Intel Python was installed. If you use different Python, please see corresponding websites.

After studying online, I installed anaconda2, and set ~/.bashrc:

moduleload anaconda/anaconda2

next, set ~/.pystartup (refer link)

import atexit import os,sys import readline import rlcompleter readline.parse_and_bind("tab: complete")

historyPath = os.path.expanduser("~/.pyhistory")

def save_history(historyPath=historyPath): import readline readline.write_history_file(historyPath)

if os.path.exists(historyPath): readline.read_history_file(historyPath)

atexit.register(save_history) del os, atexit, readline, rlcompleter, save_history, historyPath

In addition, my system is CentOS 7. The cluster is using intel compiler and Intel Python. Thus, if you are using Intel Python, please install anaconda3(may 2);else, please refer link.

Post a Comment for "How To Set Configuration For Readline In Python"