在virtualbox+centOS下安装Python的全步骤和注意事项

1. 从oracle官方网站下载virtualbox (我的是4.3.20 96996)

2. centos.org官网上下载centos (我下载的是centos 6.6 mini版 300多MB)

3. virtualbox安装

4. centos 在virtualbox中安装,注意:网卡请配置桥接模式

5. 启动centos,并设置网卡, 具体如下:

vi /etc/sysconfig/network-scripts/ifcfg-eth0


(默认onboot = no,需设置为 onboot= yes),wq!保存退出,并重启服务器

6. 升级centos,并安装开发工具

1
2
yum -y update
yum groupinstall -y 'development tools'

7.安装SSL、bz2、zlib包

1
yum install -y zlib-devel bzip2-devel openssl-devel xz-libs wget

8. 安装 Python 2.7.8

1
2
3
wget http://www.python.org/ftp/python/2.7.8/Python-2.7.8.tar.xz
xz -d Python-2.7.8.tar.xz
tar -xvf Python-2.7.8.tar

9.编译

1
2
3
4
5
6
7
8
9
10
11
12
13
# Enter the directory:
cd Python-2.7.8

# Run the configure:
./configure --prefix=/usr/local

# compile and install it:
make
make altinstall

# Checking Python version:
[root@nicetry ~]# python2.7 -V
Python 2.7.8

If you need set PATH variable check the line bellow:

1
export PATH="/usr/local/bin:$PATH"

10 安装 pip 和 virtualenv

Python安装是否结束了,我们是否遗漏了什么,对!我们需要 pip and virtualenv.

Install setuptools

1
2
3
4
5
6
7
8
wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-1.4.2.tar.gz

# Extract the files:
tar -xvf setuptools-1.4.2.tar.gz
cd setuptools-1.4.2

# Install setuptools using the Python 2.7.8:
python2.7 setup.py install

安装 pip

1
curl https://raw.githubusercontent.com/pypa/pip/master/contrib/get-pip.py | python2.7 -

最后安装 virtualenv

1
pip2.7 install virtualenv

至此,我们python 2.7.8的安装就算全部结束了


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章