Python Learning-Environment building

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

First, environmental description:

1, Centos 7 installation python3x and version management tools pyenv


Second, the environment construction:

1. Install Python -dependent libraries:

GCC make patch gdbm-devel openssl-devel sqlite-develzlib-devel bzip2-devel readline-devel

2. Install version management tool PYENV (refer to GitHub):

Curl-l Https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bi
N/pyenv-installer | Bash

After the command completes successfully, you will be prompted to change the configuration file and add the following to "~/.bash_profile" ~:

Export path= "~/.pyenv/bin: $PATH"
Eval "$ (pyenv init-)"
Eval "$ (pyenv virtualenv-init-)"

That is, add the pyenv installation path to the system environment variable. Re-login to the terminal, the modification takes effect.

Note: Try to install pyenv (ie above) using GitHub recommended amount, otherwise some plugins may not be available (because the other installation methods may not be able to install the required plug-ins, such as VIRTUALENV is installed in the form of plug-in to Pyenv).


3. Using pyenv:

A) List all installed Python versions (containing the system's own and Python version installed with pyenv)

Pyenv versions

B) List the Python version and the original version used in the current directory

Pyenv version

C) View or set the Python version of the current directory (if followed by the Python version, indicating the set version; not with the view version)

Pyenv Local

Example: Pyenv local test (sets the Python version of the current directory to the test virtual Python environment)

D) View or set the global Python version (as above)

Pyenv Global

Note: It is recommended to forget this command! (Once the system Python version is replaced, there will be a problem)

E) Create a virtual environment, primarily for version isolation

Pyenv virtualenv Version number virtual version number name

For example: pyenv virtualenv 3.5.2 Test (Create a virtual Python environment named Test, using a Python version of 3.5.2)

Note: Entering a directory in a virtual Python environment automatically activates the Python version of the virtual Python environment, and if you do not want to activate Python in a virtual environment, you can reactivate Python in the virtual environment with the command pyenv deactivate. You can use the command pyenv activate.

F) use Pyenv to install different versions of Python

Pyenv Install Python version number

Example: pyenv install 3.5.2 (python with version number 3.5.2 installed)

G) upgrade software with Pyenv

PYENV Update

H) Uninstall Pyenv

Delete the directory Rm-rf ~/.pyenv directly, and then delete the three rows in the ~/.BASH_PROFILE environment variable configuration

Note: Run the command exec "$SHELL" to make the environment variable effective, and if not, exit the terminal and reopen it.


4. Install Ipython using PIP:

Pip Install Ipython


5. Install Jupyter using PIP:

Pip Install Jupyter


6. Using Jupyter:

Jupyter is a web interface program demonstration environment, support many development languages, can use the server's development environment on the browser side, the local does not need to do any configuration, easy to use.

A) No parameter start Jupyter notebook

Jupyter Notebook

Note: The default open mode, only in the local browser access; After the command executes, the local browser is opened automatically.

B) Set parameter start Jupyter notebook

Jupyter notebook--ip=0.0.0.0--port 8899--no-browser

Note: Specify an IP of 0.0.0.0, indicating that any host in the LAN can be accessed, or you can specify port, otherwise jupyter automatically assigns an available port, usually 8888 port, specifying-no-browser, which means that the local browser does not open after startup.


PS: Need to be perfected ...

This article is from the "stupid Bird Learn to fly" blog, please be sure to keep this source http://yshun.blog.51cto.com/9570549/1812432

Python Learning-Environment building

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.