1. 程式人生 > >centos7安裝python3 以及tab補全功能

centos7安裝python3 以及tab補全功能

centos7安裝python3 以及tab補全功能

1.安裝python3

1.1下載python源碼包

網址:https://www.python.org/downloads/release/python-362/

下載地址:https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tgz

1.1.1安裝python前的庫環境,非常重要

yum install gcc patch libffi-devel python-devel  zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel -y

1.2下載,解壓安裝源碼包

wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tgz


xz -d Python-3.4.7.tar.xz
tar -xf Python-3.4.7.tar
#yum install gcc -y
./configure --prefix=/opt/python
make && make install
---------------------
用python查看默認安裝路徑
>>> import sys
>>> sys.path
[‘‘, ‘/usr/local/lib/python36.zip‘, ‘/usr/local/lib/python3.6‘, 
‘/usr/local/lib/python3.6/lib-dynload‘, ‘/usr/local/lib/python3.6/site-packages‘]
--------------------
python3.4默認沒添加path
在/etc/profile最後一行添加
export PATH=$PATH:/opt/python/bin
然後
source /etc/profile

#python快捷path就被改了,yum用的python2,麻煩

1.2.3 牛逼的python Tab自動補全

下載setuptool 3.4以上已經默認安裝了easy_install-3.4

技術分享沒什麽用

下載readline

#yum install -y readline-devel -y 
#pip install readline

tab補全
#python startup file
import readline,rlcompleter
#tab completion
readline.parse_and_bind(‘tab:complete‘)
----------------------------
python歷史記錄
#history file
import os
history_file = os.path.join(os.environ["HOME"],".pythonhistory")


本文出自 “愛生活的小白” 博客,請務必保留此出處http://sf1314.blog.51cto.com/13295031/1978791

centos7安裝python3 以及tab補全功能