内容简介:如何在CentOS6上安装Python2.7
在CentOS6上yum安装 工具 是基于 Python 2.6.6的,所以在CentOS6上默认安装的是Python2.6.6,因为要在服务器系统为CentOS6上部署生产环境,但是代码都是基于Python2.7写的,所有遇到了问题。
探索
发现系统不能卸载Python2.6后,查了系统的版本号
cat /etc/*-release
发现系统版本为CentOS6,于是开始Google搜索怎么解决。
解决办法
重新手动装一个Python2.7
准备阶段
# Start by making sure your system is up-to-date: yum update # Compilers and related tools: yum groupinstall -y "development tools" # Libraries needed during compilation to enable all features of Python: yum install -y zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel expat-devel # If you are on a clean "minimal" install of CentOS you also need the wget tool: yum install -y wget
安装Python
下载python2.7并安装
# Get Python 2.7.14: wget http://python.org/ftp/python/2.7.14/Python-2.7.14.tar.xz tar xf Python-2.7.14.tar.xz cd Python-2.7.14 ./configure --prefix=/usr/local --enable-unicode=ucs4 --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib" make && make altinstall
安装Pip
# First get the script: wget https://bootstrap.pypa.io/get-pip.py # Then execute it using Python 2.7 python2.7 get-pip.py # With pip installed you can now do things like this: pip2.7 install [packagename] pip2.7 install --upgrade [packagename] pip2.7 uninstall [packagename]
创建虚拟环境
最后可以利用venv创建一个虚拟环境(毕竟Python2.6你不能卸载)
# Install virtualenv for Python 2.7 and create a sandbox called my27project: pip2.7 install virtualenv virtualenv my27project
试一下?
# Check the system Python interpreter version: python --version # This will show Python 2.6.6 # Activate the my27project sandbox: source my27project/bin/activate # This will show Python 2.7.4 python --version
OK,搞定!
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- Golang入门:从安装、部署以及GoLand的安装开始
- Win2016上安装SFB2015先决条件安装失败:RewriteModule
- mac:Go安装和配置+GoLand安装和使用之完整教程
- Pulsar本地单机(伪)集群 (裸机安装与docker方式安装) 2.2.0
- 如何将Rancher 2.1.x 从单节点安装迁移到高可用安装
- (教科书式教程!)在VMware Workstation 14 上安装CentOS 7 【送安装包】
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。