Building a python environment under Linux

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

installation of the Linux minimization System (CENTOS6)

Install the smallest system

Ii. installing PYENV Multi-version management tools

(i) Installation steps of Pyenv

1. Install git

Yum Install Git-y

2. Install the package required for Python compilation

Yum-y install gcc make patch gdbm-devel openssl-devel sqlite-devel readline-devel zlib-devel bzip2-devel

3. Create a Python user

Useradd python

Set a password for a python user

passwd python

4. Install pyenv after login with Python user

Curl-l Https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | Bash

This sequence of commands downloads a pyenv-installer script.

If the installation prompts Curl: (+) SSL Connect error, is the issue of low NSS version, update it is possible. You need to configure a Yum source with a newer package. The configuration content is as follows:

[updates]name=centos-updatesbaseurl=https://mirrors.aliyun.com/centos/6.9/os/x86_64gpgcheck=

After saving, update NSS

Yum Update NSS

5. After the download is complete, in the Python user. Add the following in the Bash_profile

Export path= "/home/python/.pyenv/bin: $PATH" eval "$ (pyenv init-)" eval "$ (pyenv virtualenv-init-)"

Save exit and let this file take effect

. . bash_profile

(ii) Use of pyenv

1. View the current Python version

Python-v

2. List all available versions of the current system Python

Pyenv install-l

3. Install the specified version online

Pyenv Install 3.5.3-v

This installation is slow, you can use the way of offline installation, in the ~/.pyenv directory, the new cache directory, the downloaded version of the file to be installed. Not sure which file, the download of the 3 files are put in, the win under the three files into Linux, if there is no RZ command, first use yum installed # Yum install Lrzsz, and then drag 3 files into the installation # pyenv install 3.5.3-v

4. View all Python versions of PYENV management, which version the asterisk is currently managing in front of

Pyenv versions

(iii) PYENV version control of Python

1, Global (overall), using Giobal change management version, the current terminal landing Python version unchanged, the next time the user login Python version is a version of the global changed, this command is not recommended to use

Pyenv Global 3.5.3

Once set, you can turn it back on.

PYENV Global System

2, Shell, only action in the current session window, the next time to reopen the version or the original version, temporarily switch version can, not recommended to use

Pyenv Shell 3.5.3

3. Local (set locally)

First in a directory to build a folder $ mkdir-p magedu/projects/web, switch to this directory, execute $ pyenv local 3.5.3, his role is to switch versions in the current directory, only valid for the current directory, if he has other directories below, The version of the switch is inherited to his subdirectory, and if it is returned to the previous directory or other directory, the version is original.

(iv) Virtual environment

1, the use of the Python environment is a public space, if more than one project using a different version of Python development, or use a different version of Python deployment run, or use the same version of the different projects using different versions of the library, and so on, and so on these problems will bring conflict. The best solution is for each project to run its own "isolated small environment" independently, creating a virtual version space.

Pyenv virtualenv 3.5.3 wang353

2, build a directory, in the directory you want to deploy the virtual environment to deploy the virtual version of wang353, this directory is created virtual environment, out of this directory is not managed by this version.

Pyenv Local wang353

3, now can be in this virtual environment of their own independent development, in this virtual environment to install Ipython.

Third, installation Ipython

(i) Installing Ipython using the PIP tool

1, Pip is a Python package management tool, 3.x version directly with, can be used directly, and Yum in order to use the domestic image, the PIP source is set as follows: first CD switch to the more directory, Create a. Pip hidden folder and create a touch in this folder with an empty file ending in. conf.

Cdmkdir. pipcd. Pip/touch Pip.confvim pip.conf

The contents are:

[global]index-url=https://mirrors.aliyun.com/pypi/simple/trusted-host=mirrors.aliyun.com

2. Installing Ipython in a virtual environment

Pip Install Ipython

Will prompt for an upgrade

Pip Install--upgrade pip

3, Ipython can now use the

Ipython

(ii) Installing Jupyter using the PIP tool

1, directly using the PIP command to install Jupyter can be

Pip Install Jupyter

2. Set a password for Jupyter

Jupyter Notebook Password python

3, this time if directly open jupyter is not possible, you need to set the IP

Jupyter Notebook--ip=0.0.0.0

4, using the native ip:8888 in the browser to access the

5. If you cannot access it, you need to turn off the firewall

Service Iptables Stopchkconfig iptables off


Building a python environment under Linux

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: info-contact@alibabacloud.com 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.