The Python learning environment and tools you will use

Source: Internet
Author: User
Tags delete key readline virtual environment jupyter jupyter notebook aliyun

Note: so the operating system environment used for CentOS 6.2

Compiling and installing Python 2.7 and Ipython

1. Download the required Packages

ipython-1.2.1.tar.gz PYTHON-2.7.6.TAR.XZ # Please download the specified package from the official website.

2. Install the ReadLine package with Yum

~]# yum-y Install Readline-devel

If you do not install this package, it is possible that the Python interface will not be able to use the DELETE key "Backspace"

3. Install GCC package, prepare for compiling python

~]# yum-y Install gcc

4. Unzip and install python2.7

~]# tar XF python-2.7.6.tar.xz ~]# CD Python-2.7.6 ~]#./configure--prefix=/usr/local/python27 ~]# make && ma Ke Install

Ipython is an enhanced Python command-line interface that supports automatic variable completion, automatic indentation, and built-in features and functions

~]# tar XF ipython-1.2.1.tar.gz ~]# CD ipython-1.2.1 ~]#/usr/local/python27/bin/python2.7 setup.py Build ~]#/usr/loc al/python27/bin/python2.7 setup.py Install

6. Create a link path

~]# ln-sv/usr/local/python27/bin/python2.7/usr/bin/python27 ~]# ln-sv/usr/local/python27/bin/ipython/usr/bin/

7. Enable PYTHON27 and Ipython Interactive interface

Deploying Python using Pyenv

The role of Pyenv

    • Installing the Python Interpreter

    • Managing Python versions

    • The ability to manage Python virtual environments (equivalent to a separate version) via plugins

Operation Steps

1. Install git

~]# yum-y Install git

2. Define Pyenv_root

~]# Export Pyenv_root=/opt/pyenv

3. Get the installation method using bash from official website

# official Link Https://github.com/yyuu/pyenv-installer # Execute installation Instructions ~]# Curl-l https://raw.githubusercontent.com/yyuu/ Pyenv-installer/master/bin/pyenv-installer | Bash

4. Configure the required environment variables

~]# vim/etc/profile.d/pyenv.sh Export path= "/opt/pyenv/bin: $PATH" eval "$ (pyenv init-)" eval "$ (pyenv virtualenv-init- ) "# details can be seen above the installation after the message ~]# sh/etc/profile.d/pyenv.sh

5, test pyenv is normal

~]# pyenv Version System (set by/root/.pyenv/version) # when the above output information indicates that your PYENV installation is working properly pyenv install Python 3.5.2

1. Install all required Packages

~]# yum-y Install gdbm-devel openssl-devel sqlite-devel readline-devel zlib-devel bzip2-devel patch

2. Use pyenv to directly install Python 3.5.2

# If the above installation pyenv Normal, you can use the following command to install the ~]# pyenv installed 3.5.2

For more information on pyenv, please see the Help documentation

Supplemental cannot install the latest Python

You can use pyenv install-list to see which version you can install, and if you belong to an earlier installation of pyenv, chances are you won't be able to use the latest version of Python, update your pyenv with update

~]# pyenv Install--list # See the Python program version you can install ~]# pyenv Update # Update PYENV program installation progress is slow

It is slow to install Python 3.5.2 directly using pyenv install 3.5.2 above, because the steps for this installation are downloaded from a foreign website. So we can first store the files we want to install in the cache directory, so that when the installation is performed, he will first get from the cache directory, so that the installation progress can be accelerated

# cache Directory is ~/.pyenv/cache ~]# mv Python-3.5.2.tar.xz ~/.pyenv/cache/python-3.5.2.tar.gz # This operation can still be slow, because in addition to downloading Python 3.5.2, you need to get some other program files, so you can only wait patiently. # Please download the specified package from the official website pyenv basic usage

Pyenv has the ability to manage our Python virtual environment, which means we can install multiple versions of Python on a single server for us to learn to use

Simple introduction to commonly used commands

    • pyenv Install python_version   installs the specified PYTHON version, such as pyenv install 3.5.2

    • pyenv Local pyenv_version   Sets the current directory to Python version, the current directory and its subdirectories will use the same version of Python

    • pyenv versions View all existing versions of Python installed

      ~]# pyenv Versions * System (set by/root/.pyenv/version)   # default Python version 2.7.6   # This version of Python use the method above to install 3.5.2

    • pyenv version   current directory uses Python versions

      ~]# pyenv Version System (set by/root/.pyenv/version)

Set the Python2 directory to Python 2.7.6 version of python~]# cd/root/python2 ~ python2]# pyenv local 2.7.6 ~ python2]# pyenv version 2.7.6 (s ET by/root/python2/.python-version)


Set the Python3 directory to Python 3.5.2 version of python~]# cd/root/python3 ~ Python3]# pyenv Local 3.5.2 ~ Python3]# pyenv version 3.5.2 (s ET by/root/python3/.python-version)


Since then we can use different versions of Python based on different directory operations.

Install Jupyter notebook Learn to use

Jupyter Notebook is a web-version of Python authoring interactive mode, which functions like Ipython, but he uses the same process as we do with paper and pen, and we can easily erase the code we wrote earlier. And he can keep a record of our written code, which is quite handy for taking notes and writing simple code. So let's see how to install using Jupyter notebook1, install pip

Pip is a tool for installing and managing Python packages that can be used to install the tools we need for some of our programs, such as our ipython,jupyter notebook, etc.

~]# vim ~/.pip/pip.conf [global] Index-url = http://mirrors.aliyun.com/pypi/simple/# update download path, similar in principle to our yum source trusted-host = Mirrors.aliyun.com # Indicates a package that trusts this site # If this directory does not exist, remember to create

2. Install Jupyter with PIP

~]# pip Install Jupyter

3. Start Jupyter Notebook

~ Python2]# jupyter notebook--ip=0.0.0.0--no-browser # What is the Python version of your current directory, and what version of Python will he use to run #--ip: Indicates the IP address you are listening to #--n O-browser: Indicates that no local default browser is used to open the # Jupyter notebook The default listener port is 8888

4. Open the browser, log in to Jupyter notebook, and use

Browser input Http://192.168.80.111:8888/tree to open

650) this.width=650; "src=" http://si1.go2yd.com/get-image/0A33WGenJ68 "style=" border:0px;margin:20px 0px; "alt=" 0a33wgenj68 "/>

We can also enable multiple versions of multiple Jupyter notebook programs, just go into a different Python environment to perform the boot, and he will create another port for listening.

Using the Pycharm IDE tool to connect to the Linux Python environment under Windows

We generally use desktop computer systems or Windows-based, although the Python environment can also be deployed on windows, but there are many incompatibilities under Windows, and the future need to install the modules are more troublesome, It is recommended that you deploy a Python environment on Linux and then use Pycharm to remotely connect to Linux for Python development

Pycharm is a very good Python IDE development tool

1. Download and install Pycharm from official website

Website link http://www.jetbrains.com/pycharm/download/#section =windows recommend installing professional, because community will be much less than professional. This document is using the Pycharm 2016.2.3 Professional version

2. Add configuration to connect remote server 2.1, open pycharm, click File  →settings→project scripts→project interpreter   Select "Add remote" 650) t his.width=650; "src=" http://si1.go2yd.com/get-image/0A33WDpLD8q "style=" border:0px;margin:20px 0px; "alt=" 0a33wdpld8q "/>2.2, click Select SSH Credentials, and according to their own environment fill similar parameters 650) this.width=650; src= http://si1.go2yd.com/ Get-image/0a33wc8ubxy "style=" border:0px;margin:20px 0px; "alt=" 0a33wc8ubxy "/>3, configure shared directory The script file we use by default is stored under Windows, If you want to use Pycharm to run scripts written directly is not possible, so we set up a directory, the written script files are automatically uploaded to Linux. 3.1 Tap File→settings→build, execution, deployment→deployment, click +, select "SFTP" 650) this.width=650; "Src=" http://si1.g O2yd.com/get-image/0a33walsooo "style=" border:0px;margin:20px 0px; "alt=" 0a33walsooo "/>3.2 Configure the appropriate parameters, including the local code storage path, Linux code storage path, remote server IP, account password and other parameters 650) this.width=650; "src=" Http://si1.go2yd.com/get-image/0A33W89WSlU "style=" border:0 px;margin:20px 0px; "alt=" 0a33w89wslu "/>

650) this.width=650; "src=" Http://si1.go2yd.com/get-image/0A33W75C9Ca "style=" border:0px;margin:20px 0px; "alt=" 0a33w75c9ca "/>3, set code automatic upload in order to open tools→deployment→automatic Upload (always) 650) this.width=650;" src= "http:// Si1.go2yd.com/get-image/0a33w9yrh5s "style=" border:0px;margin:20px 0px; "alt=" 0a33w9yrh5s "/> If there is no problem with the previous configuration, Then create a new code file and save it, and he will automatically upload it to the/root/python2/scripts directory under Linux. Then the code written under Pycharm can be executed directly at this point.

Similarly, Python 3 is also configured so that the reader should try



Article Source: Marco Education

Official: Marco Linux operations

Technology Exchange Group: 485374463


This article is from the "Marco Linux Training" blog, so be sure to keep this source http://mageedu.blog.51cto.com/4265610/1890616

The Python learning environment and tools you will use

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.