Python Practical Environment pyenv Construction Tutorial

Source: Internet
Author: User
Tags virtual environment virtualenv jupyter

Experimental system: KUBUNTU-15.10-DESKTOP-AMD64

Introduction to PYENV: Generally in the operating system we will install multiple versions of Python, in the *nix system generally by default comes with the Python2 and Python3 two versions, so in the Python version switch will be more troublesome, PYENV provides a simple way. Pyenv is a simple and elegant tool that can be easily toggled in multiple versions of Python.

Pyenv has the following features:

    • Make a global python version switch

    • Provide a Python version for a single project

    • Using environment variables allows you to rewrite the Python version

    • Ability to perform command searches between different versions at the same time

Has the following characteristics:

    • Depends only on Python itself

    • Add directories to $path to use

    • Ability to perform VIRTUALENV management

1. Install the pre-dependency package:

sudo Install  Make wget Curl LLVM libncurses5-dev libncursesw5-dev git vim

2. Use the script to quickly install Pyenv:

Curl-l Https:// | bash

3. After the installation is complete, configure the environment variables according to the contents of the pyenv prompt:



vim ~/.bash_profile------------------------------------------->
Export path= "/home/jason/.pyenv/bin: $PATH"
Eval "$ (pyenv init-)"
Eval "$ (pyenv virtualenv-init-)"
SOURCE ~/.bash_profile // Edit save complete, please source it to make sure it takes effect

4. Test whether the installation was successful and install the specified version of Python:

Pyenv-v         // check appears, indicating successful installation 


To install Python:

Install  Less   // to view the versions that can be installed Install 3.4. 2          // Specify a version to install
pyenv versions View Installed Versions



5. Configure the virtual directory and install Ipython:

mkdir Test                    // Create a working directory   3.4. 2 Test   // Create a virtual environment based on a version 
Pyenv Local test // Set this directory as the environment
Pip Install Ipython // install Ipython for this environment

In use, you can see the virtual environment through pyenv Virtualenvs , I can see there is already a test.

When I do not work in this directory, the Python version is the system default of 2.7.10. When I switched to the test directory, the Python version became the 3.4.2 I just set up, which is very handy.



6. Additional expansion, using Jupyter:

Jupyter is the product of stripping the IPython and Python interpreter, and will gradually replace the IPython independent release. Jupyter can be combined with programs outside of Python to provide new and powerful services. such as Ruby REPL environment Iruby and Julia REPL environment Ijulia.

CD test                          // enter into the virtual environment just under install--ip=0.0.  0.0   // run


My virtual machine IP is, in the browser open, you can access to the page. Create a Python3 page and start running the code on the Web side. It also supports markdown, and you can try it on your own.



Here, the demonstration is over, thank you for watching, thank you!

Python Practical Environment pyenv Construction Tutorial

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.