Problems with Linux Python

Source: Internet
Author: User

The following error occurred while using Yum

File "/usr/bin/yum", line 30

Except Keyboardinterrupt, E:

^

Syntaxerror:invalid syntax

This is caused by the upgrade of Python

Vim/usr/bin/yum

Change #!/usr/bin/python2 to #!/usr/bin/python2.6


--------------------------------------

Direction key garbled

Arrow keys appear ^[[a^[[b^[[d^[[c^h when using Python

The CentOS 6.5 default installs only the ReadLine module and does not install the Readline-devel module, so just install it

Yum Install Readline-devel-y

Enter the Python3 source directory, recompile

Make

Make install


--------------------------------------------

Tab Auto-complete

Installing ReadLine

Yum Install readline*-y

Create a Pythonstartup file, place it anywhere, I put it under/usr/local/python3.

# python startup fileimport sysimport readlineimport rlcompleterimport atexitimport os# tab Completionreadline.parse_and _bind (' Tab:complete ') # History filehistfile = Os.path.join (os.environ[' HOME '), '. Pythonhistory ') Try:readline.read_ History_file (histfile) except IOError:passatexit.register (Readline.write_history_file, histfile) del os, Histfile, ReadLine, Rlcompleter

Adding environment variables in ~/.bash_profile

Export Pythonstartup=/usr/local/python3/pythonstartup

Refresh Configuration

source. bash_profile




Problems with Linux Python

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.