Python Installation Preparation

Source: Internet
Author: User
Tags virtual environment virtualenv jupyter jupyter notebook install redis aliyun

First, the Python installation preparation Python

Dutch Guido van Rossum,2005 joins Dropbox for google,2013 year

1989, the creation of the Python language, in early 1991 released the first public release version
Python philosophy
>>> Import this
The Zen of Python

2.x and 3.x differences
Statement is functional, such as print 1 2, but 2.x means print statement printing tuple, 3.x meaning is a function of 2 parameters
Divisible, for example 1/2 and 1//2,3.x versions/for natural divide
Raw_input renamed as input in 3.x, no longer using raw_input
Round function, the rounding of I.5 in 3.x becomes the nearest even
Unicode for uniform use of strings
Exception capture, thrown syntax change

Python environment to build development environment-PYENV

Python Multi-version management tool
Managing the Python Interpreter
Managing Python Multiple Versions
Managing a Python virtual environment
Official website Https://
Windows not supported, reason HTTPS://GITHUB.COM/PYENV/PYENV/ISSUES/62

Linux System Preparation

Prepare the Linux minimum system.
If you clone in a virtual machine, the MAC address will change.
Use CentOS 6.5+ here
Note Several questions:
The network adapter in the virtual machine is recommended to use NAT mode, and the future Python program deployment requires an extranet connection

IP address ipaddr=

Mask netmask=

Gateway Geteway=
Rm-rf/etc/udev/rules.d/70-persistent-net.rules, delete this file

Servece iptables Stop shutting down the firewall

Vi/etc/sysconfig/selinux Setting Parameters selinux=disabled

Restart the machine and make a snapshot

Yum Install git-y git

Yum-y install gcc make patch gdbm-devel openssl-devel sqlite-devel readline-devel zlib-devel bzip2-
Devel installing Python compilation dependencies

Create user Python
# Useradd Python
# echo Python | passwd python--stdin

PYENV official website Https://
Pyenv-installer plug-in Https://

Curl-l Https:// | Bash


1. Installation documentation in Https://

2. If Curl appears curl: (+) SSL Connect error, is the issue of low NSS version, update it. The current NSS version is only 3.15.

You may need to configure a Yum source with a newer package, and the etc/yum.repo.d/file ends with a. Repo:


Update Yum Update NSS

Append to Python user's ~/.bash_profile

Export path= "/home/python/.pyenv/bin: $PATH"
Eval "$ (pyenv init-)"
Eval "$ (pyenv virtualenv-init-)"
$ source ~/.bash_profile

When the user starts, the script in the user's. Bash_profile is executed and the pyenv is started.
The installed pyenv is in the ~/.pyenv directory.

Pyenv Install--list list available versions

Pyenv Install 3.6.6 installation 3.6. Version 6

PYENV versions viewing installed versions

Such installation may be slow, in order to speed up, but choose the cache method.
Install using cache mode

In the ~/.pyenv directory, create a new cache directory and put the downloaded file to the installed version.
Not sure which file to take, the downloaded XZ, GZ, tgz These files are placed in the cache directory.
$ pyenv Install 3.5.3-v

Pyenv Global 3.5.5

Pyenv the Python version of the local 3.5.3 inheritance setting

Pyenv Shell 3.5.3

Pyenv Local--unset

VIRTUALENV Virtual Environment settings
Why use a virtual environment?
Because the Python environment you just used is a public space, if multiple projects are developed using a different Python version, or using a different
Python versions are deployed, or are developed using the same version, but different projects use different versions of the library, and so on, these problems will bring
Process. The best solution is for each project to run its own "isolated small environment" independently of each other.
Using plugins, in plugins/pyenv-virtualenv
$ pyenv virtualenv 3.5.3 mag353
Create a separate virtual space using the Python 3.5.3 version.

$ pyenv Versions
* System (Set By/home/python/.pyenv/version)

Can be displayed in the version list, and 3.5.3 is the same, is a version of the.

The real directory under ~/.pyenv/versions/, as long as the use of this virtual version, the package will follow the corresponding directory down, instead of using 3.5.3

Pip is Python's package management tool, 3.x version directly with, can be used directly.
As with Yum in order to use the domestic image, the following configuration.

$ mkdir ~/.pip
Configuration file in ~/.pip/pip.conf


Windows system
The configuration file for the PIP under Windows is ~/pip/pip.ini, as in the following
Home directory for Windows, type "." In "Run".

PIP Package Manager
Pip Install XXX yyy
PIP List
PIP Search keyword or pypi
Pip Help Install
PIP configuration
$ vim ~/.pip/pip.conf
The domestic source of Tsinghua and watercress

PIP Package Manager
Pip Install Redis Ipython
Pip Install Jupyter
PIP Freeze > Requirement
PIP Install-r Requirement

IPython Jupyter
Enhanced Python shell, auto-complete, auto-indent, support Shell, add a lot of functions
Jupyter Notebook Password
Jupyter Notebook--ip=
It is independent of the project from the Ipython
Stand-alone interactive notebooks with Ipython in the background
Shortcut keys: Shift + ENTER, Ctrl + ENTER, DD, M

Build projects, write code, run

Python Installation Preparation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.