Python Env


簡介:python

記錄 CentOS 6.x Python 環境的安裝步驟。

1、安裝依賴包c++

shell > yum -y install epel-release
shell > yum -y install gcc gcc-c++ wget readline-devel zlib-devel openssl-devel sqlite-devel

shell > python -V
Python 2.6.6

1、安裝 Python 2.7sql

shell > cd /usr/local/src; wget -c https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz
shell > tar zxf Python-2.7.13.tgz
sehll > cd Python-2.7.13
shell > ./configure && make && make install

shell > python2 -V
Python 2.7.13

2、安裝 Python 3.5shell

shell > cd /usr/local/src; wget -c https://www.python.org/ftp/python/3.5.4/Python-3.5.4.tgz
shell > tar zxf Python-3.5.4.tgz
shell > cd Python-3.5.4
shell > ./configure && make && make install

shell > python3 -V
Python 3.5.4

3、安裝 Virtualenvui

shell > pip3 install virtualenv

4、建立不一樣的 Python 環境spa

一、Python 2.xcode

shell > virtualenv --no-site-packages -p python2 py2.x
shell > source py2.x/bin/activate

(py2.x) shell > python -V
Python 2.7.13

(py2.x) shell > pip install ipython

(py2.x) shell > ipython
Python 2.7.13 (default, Aug 9 2017, 20:15:06) 
Type "copyright", "credits" or "license" for more information.

IPython 5.4.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.

In [1]:

(py2.x) shell > deactivate
# 建立了一個 python2 的虛擬環境 名稱爲 py2.x,以後激活這個虛擬環境
# 能夠看到默認的 python 版本已經不是原來的 2.6.6
# 使用 pip 安裝 ipython 軟件包
# ipython 調用的 python 版本也是 2.7.13
# 退出虛擬環境

二、Python 3.xorm

shell > virtualenv --no-site-packages -p python3 py3.x
shell > source py3.x/bin/activate

(py3.x) shell > python -V
Python 3.5.4

(py3.x) shell > pip install ipython

(py3.x) shell > ipython
Python 3.5.4 (default, Aug 9 2017, 21:57:01) 
Type 'copyright', 'credits' or 'license' for more information
IPython 6.1.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]:

(py3.x) shell > deactivate

# Endsqlite

相關文章
相關標籤/搜索