1.1 Installing Python
Lubuntu-16.04.4-desktop-i386 as the OS for the Python development environment.
1.1.1 Installing the Deb Package
Ubuntu can use the Apt-get command to manage the pack. Let's start by updating all the packages and installing some of the packages needed for Python development.
List 1.1 Deb package updates, upgrades, packages required for Python development
$ sudo apt-get -y update$ sudo apt-get -y upgrade$ sudo apt-get -y install build-essential$ sudo apt-get -y install libsqlite3-dev$ sudo apt-get -y install libreadline6-dev$ sudo apt-get -y install libgdbm-dev$ sudo apt-get -y install zlib1g-dev$ sudo apt-get -y install libbz2-dev$ sudo apt-get -y install sqlite3$ sudo apt-get -y install tk-dev$ sudo apt-get -y install zip$ sudo apt-get -y install libssl-dev
List 1.2 Installing Python-related packages
# 安装python-dev$ sudo apt-get -y install python-dev# 安装pip$ wget https://bootstrap.pypa.io/get-pip.py$ sudo python get-pip.py
List 1.3 Viewing versions of Python
$ python -VPython 2.7.12
1.1.2 Installing third-party packages
Use the PIP Install command to install a third-party developed package.
List 1.4 Viewing the version of PIP
$ pip --versionpip 9.0.1 from /usr/local/lib/python2.7/dist-packages (python 2.7)
List 1.5 Install Virtualenv package with PIP
$ sudo pip install virtualenv
How to use 1.1.3 virtualenv
List 1.6 View version of Virtualenv
$ virtualenv --version15.1.0
List 1.7 View current installation version with PIP freeze
$ pip freezechardet==2.3.0defer==1.0.6psutil==3.4.2pygobject==3.20.0pysqlite==2.7.0python-apt==1.1.0b1+ubuntu0.16.4.1python-debian==0.1.27pyxdg==0.25six==1.10.0virtualenv==15.1.0
List 1.8 Build VIRTUALENV environment
$ mkdir ~/work$ cd ~/work$ virtualenv venv
List 1.9 Start virtualenv environment
$ source venv/bin/activate(venv) [email protected]irtual-machine:~/work$
List 1.10 Viewing versions in a virtual environment
(venv) $ pip freeze$
List 1.11 Close VIRTUALENV Environment
(venv) $ deactivate$
If we no longer need a virtualenv environment (in this case, the venv directory), you can rm -R venv
delete it directly with the directory, such as the command.
1.1. Use of more than 4 versions of Python
List 1.12 Viewing versions of Python
$ python3 -VPython 3.5.2$ python -VPython 2.7.12
List 1.13 Specifies the Python executed under Virtualenv
$ virtualenv --python=/usr/bin/python venv2$ source venv2/bin/activate(venv2) $ python -VPython 2.7.12$ deactivate$$ virtualenv --python=/usr/bin/python3 venv3$ source venv3/bin/activate(venv3) $ python -VPython 3.5.2$ deactivate$
1th. Getting Started with Python