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")
时间: 2024-10-01 02:38:57