CentOS 6.7 final编译安装配置 Python 环境
2016-05-07 09:53
891 查看
CentOS 6.7默认的Python版本为2.6.6,现升级为Python 2.7.111、安装编译环境
可以把python目录下的bin目录加入系统环境变量: echo 'export PATH=$PATH:/usr/local/python/bin' > /etc/profile.d/py.sh
sh /etc/profile.d/py.sh
重新会话登录后生效。7、查看版本
9、其他用到的:
1)安装pip:
wget https://bootstrap.pypa.io/get-pip.py python get-pip.py
2)设置python命令行补全功能:
pip install readline
cat ~/.pystartup
# Add auto-completion and a stored history file of commands to your Python# interactive interpreter. Requires Python 2.0+, readline. Autocomplete is# bound to the Esc key by default (you can change it - see readline docs).## Store the file in ~/.pystartup, and set an environment variable to point# to it: "export PYTHONSTARTUP=~/.pystartup" in bash.
import atexitimport osimport readlineimport 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
立即生效:
export PYTHONSTARTUP=~/.pystartup
重启生效:echo "export PYTHONSTARTUP=~/.pystartup" >> /etc/profile.d/py.sh
3)安装Ipython更加直接方便,安装命令: pip install ipython 使用: ipython
yum groupinstall "Development tools"2、安装依赖的包
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel3、下载Python
wget https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tgz tar zxvf Python-2.7.11.tgz cd Python-2.7.114、编译安装
./configure --prefix=/usr/local/python make && make install5、直接调用
/usr/local/python/bin/python6、替换旧版本 ln -sf /usr/local/python/bin/python /usr/bin/python
可以把python目录下的bin目录加入系统环境变量: echo 'export PATH=$PATH:/usr/local/python/bin' > /etc/profile.d/py.sh
sh /etc/profile.d/py.sh
重新会话登录后生效。7、查看版本
python -V
Python 2.7.118、升级后yum出错的解决方法使用该方法升级Python可能会导致yum对python的依赖版本不对,可以修改/usr/bin/yum文件首行改为:
#!/usr/bin/python2.6
9、其他用到的:
1)安装pip:
wget https://bootstrap.pypa.io/get-pip.py python get-pip.py
2)设置python命令行补全功能:
pip install readline
cat ~/.pystartup
# Add auto-completion and a stored history file of commands to your Python# interactive interpreter. Requires Python 2.0+, readline. Autocomplete is# bound to the Esc key by default (you can change it - see readline docs).## Store the file in ~/.pystartup, and set an environment variable to point# to it: "export PYTHONSTARTUP=~/.pystartup" in bash.
import atexitimport osimport readlineimport 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
立即生效:
export PYTHONSTARTUP=~/.pystartup
重启生效:echo "export PYTHONSTARTUP=~/.pystartup" >> /etc/profile.d/py.sh
3)安装Ipython更加直接方便,安装命令: pip install ipython 使用: ipython
相关文章推荐
- Linux socket 初步
- Linux Kernel 4.0 RC5 发布!
- Python动态类型的学习---引用的理解
- Python3写爬虫(四)多线程实现数据爬取
- 垃圾邮件过滤器 python简单实现
- linux lsof详解
- linux 文件权限
- Linux 执行数学运算
- 下载并遍历 names.txt 文件,输出长度最长的回文人名。
- 10 篇对初学者和专家都有用的 Linux 命令教程
- Linux 与 Windows 对UNICODE 的处理方式
- Ubuntu12.04下QQ完美走起啊!走起啊!有木有啊!
- 解決Linux下Android开发真机调试设备不被识别问题
- 运维入门
- 运维提升
- Linux 自检和 SystemTap