根据问题的答案,我安装了python的readline来解决退格问题。如果我以根用户身份登录 CentOS 7,我可以毫无问题地退格;但是,如果我以用户身份登录,我必须运行pip install readline
来解决退格问题。我不知道在哪里设置阅读行,因此每次以用户身份登录时都不需要重新安装它。在我的计算机中,它没有定义在其中一个解决方案中提到的"PYTHONSTARTUP"。任何进一步的帮助和建议将不胜感激。
注意:我的系统是 CentOS 7。已安装英特尔 Python。如果您使用不同的 Python,请参阅相应的网站。
在线学习后,我安装了 anaconda2,并设置了 ~/.bashrc:
module load anaconda/anaconda2
接下来,设置 ~/.pyStartup (参考链接(
出口处导入 导入操作系统,系统导入读取线导入rlcompleter readline.parse_and_bind("选项卡:完成"(
historyPath = os.path.expanduser("~/.pyhistory"(
def save_history(historyPath=historyPath(: 导入阅读行 readline.write_history_file(历史路径(
如果 os.path.exists(historyPath(: readline.read_history_file(历史路径(
atexit.register(save_history( del os, atexit, readline, rlcompleter, save_history, historyPath
此外,我的系统是 CentOS 7。该集群使用英特尔编译器和英特尔 Python。因此,如果您使用的是Intel Python,请安装anaconda3(5月2日(;否则,请参阅链接。