Build Python's Running environment

Source: Internet
Author: User
Tags virtual environment virtualenv

Creating a Python virtual run environment with VIRTUALENV

When you write a Python program, you typically use some third-party library files. and different projects usually call different third-party libraries. If all the projects are mixed together, this is obviously not easy to manage. Virtualenv is a virtual environment management tool.

$ sudo pip install virtualenv
$ virtualenv Project1
$ source./project1/bin/activate
(Project1) [Email protected]:~$

Create a Python virtual run environment using VENV

Python version 3.3 and above has a venv module in the standard library, and this module and virtualenv implement similar functions. If your system does not contain a venv module, we can also install it by command.

$ sudo apt-get install python3-venv
$ python3-m venv VENV1
$ source Venv1/bin/activate
(VENV1) [Email protected]:~$

Create a coexistence of different versions using pyenv

The main function in the previous two methods is to implement different Python runtime environments in one operating system, with the same Python version of the software. Pyenv is a good choice if we want to quickly save a different Python version of the operating environment. Pyenv is an open source project whose source code is hosted on GitHub and GitHub's address is https://github.com/pyenv/pyenv.

$ sudo apt-get update
$ sudo apt-get install make build-essential libssl-dev Zliblg-dev
$ sudo apt-get install Libbz2-dev libreadline-dev libsqlite3-dev wget Curl
$ sudo apt-get install LLVM libncurses5-dev Libncursesw5-dev
$ curl-l Https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | Bash
$ pyenv Update
$ pyenv Install-list
$ pyenv Install 3.6.2

It may take some time to install a new version of Python. The new Python version is installed directly from the source code due to different operating system environments. After the installation is complete, we can view the software version on the current system.

$ pyenv Versions

Set the global Python software version

$ pyenv Global 3.6.2
$ pyenv Versions

At this point, when we execute the Python program again, we have already used the 3.6.2 version.

Creating a Python runtime environment using Docker

Links: https://www.oschina.net/translate/using-docker-as-a-python-development-environment

Build Python's Running environment

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.