Python Environment setup

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

1.1.1  1python Multi-version management tool PYENV installation

1. Role

Managing the Python interpreter, Python version, Python's virtual environment

Software: https://github.com/pyenv/pyenv

2.PYENV Package Installation

A. Configure the Yum source (config file contents below)

VI Centos6-base-163.repo

[Base]

name=centos-$releasever-base-163.com

baseurl=http://mirrors.163.com/centos/6/os/$basearch/

Enable=1

Gpgcheck=0

Gpgkey=http://mirror.centos.org/centos/rpm-gpg-key-centos-6

#released Updates

[Updates]

name=centos-$releasever-updates-163.com

baseurl=http://mirrors.163.com/centos/6/updates/$basearch/

Gpgcheck=0

Enable=1

Gpgkey=http://mirror.centos.org/centos/rpm-gpg-key-centos-6

#additional packages that could be useful

[Extras]

name=centos-$releasever-extras-163.com

baseurl=http://mirrors.163.com/centos/6/extras/$basearch/

Gpgcheck=0

Enable=1

Gpgkey=http://mirror.centos.org/centos/rpm-gpg-key-centos-6

#additional packages that extend functionality of existing packages

[Centosplus]

name=centos-$releasever-plus-163.com

baseurl=http://mirrors.163.com/centos/6/centosplus/$basearch/

Gpgcheck=0

Enabled=1

Gpgkey=http://mirror.centos.org/centos/rpm-gpg-key-centos-6

#contrib-packages by Centos Users

[Contrib]

name=centos-$releasever-contrib-163.com

baseurl=http://mirrors.163.com/centos/6/contrib/$basearch/

Gpgcheck=0

Enabled=1

Gpgkey=http://mirror.centos.org/centos/rpm-gpg-key-centos-6

B. Install Git software and dependency packages

Yum Install Git-y

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

C. Create a user

Useradd python

passwd python

D. Install pyenv software

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

E. Configure Environment variables

Vim ~/.bash_profile

Export path= "/home/python/.pyenv/bin: $PATH"

Eval "$ (pyenv init-)"

Eval "$ (pyenv virtualenv-init-)"

1.1.2  3. Installing and managing Python using pyenv Software

A. List all available versions

Pyenv versions

B. Install the specified Python version

Pyenv Install--list

Pyenv Install 3.5.3–v

/home/python/.pyenv

/home/python/.pyenv/cache---Need to be built manually

C, create a directory to have local bundled in a directory

PYENV versions------Use the Pyenv tool to view the currently installed Python version

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

3.5.3

3.6.1

3.6.3

Mkdir-p magedu/projects

CD magedu/projects/

Pyenv Local 3.5.3----------------#让python版本捆绑在一个目录下

Python-v

Python 3.5.3

CD-------#你看如果在其它目录, the Python version is the system default 2.6,local login Basic Isolation

Python-v

Python 2.6.6

Pyenv virtualenv Usage

Pyenv virtualenv 3.6.3 mage363

Pyenv versions

System

3.5.3

3.6.1

* 3.6.3 (set by/home/python/magedu/projects/web/.python-version)

3.6.3/envs/mage363

* MAGE363 (set by/home/python/magedu/projects/web/.python-version)

Pyenv Local mage363

(mage363) [Email protected] web]$

1.2     Development tools Ipython Notebook Installation 1.2.1  1. Configure PIP Domestic source

Mkdir/root/.pip

Vim/root/.pip/pip.conf

[Global]

Index-url = http://mirrors.aliyun.com/pypi/simple/

[Install]

Trusted-host=mirrors.aliyun.com

Pip-v

Pip 9.0.1 from/home/python/.pyenv/versions/3.5.3/lib/python3.5/site-packages (Python 3.5)

1.2.2  2, Installation Jupyter

Pip Install IPython

Pip Install urllib3– installation Ipython notebook dependencies

Pip Install jupyter– installation Ipython Notebook

1.2.3  3. Start and Change password

Jupyter notebook--ip=0.0.0.0--port 8000--allow-root--no-browser

http://192.168.12.128:8080/

jupyter Notebook--generate-config----- build configuration file

Production passwords and modification profiles

Preparing a hashed password

Ipython

You can prepare a hashed password manually, using the function notebook.auth.security.passwd ():

In [1]: From notebook.auth import passwd

In [2]: passwd ()

Enter Password:

Verify Password:

OUT[2]: ' Sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed '

VI jupyter_notebook_config.py ( add a password line )

C.notebookapp.password = U ' sha1:a025bae1e107:247f2a22dbd90d2bbeb0aa4e4af6cb3268dcee8f '

Restart verification

Jupyter notebook--ip=0.0.0.0--port 8000--allow-root--no-browser

1.3     3 using the PIP tool to quickly import export packages into different projects 1.3.1  1, next in this environment, the installation of all packages exported:

(magedu353) [Email protected] cmdb]$ pip Freeze >/tmp/packs.txt

(magedu353) [Email protected] cmdb]$ Cat/tmp/packs.txt

1.3.2  2. #我们去web环境目录

Pip Install-r/tmp/packs.txt

#这样就相当于在部署跟cmdb上的环境包了 (Import Package)

1.4     4win Development Tools Pycharm installation 1,  Jupyter Installation

Installation

Pip Install Jupyter

Start

Jupyter Notebook


Python Environment setup

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.