Mac uses pyenv for Python version management

Source: Internet
Author: User
mac uses pyenv for Python version management

Previously are directly to the official website to download python3.4 pkg package to install, because to involve the modification of soft connections, it is very easy to go wrong. A recent attempt at pyenv to install. Install pyenv

Install
$ curl-l Https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | Bash
Update
$ pyenv Update
Uninstall
$ rm-fr ~/.pyenv

See:

Https://github.com/yyuu/pyenv-installer

The pyenv is now installed to the current user's ~/.pyenv directory.
Also, you need to copy the following code into ~/.BASHRC:

Export pyenv_root= "${home}/.pyenv"
If [-D "${pyenv_root}"]; Then
Export path= "${pyenv_root}/bin:${path}"
Eval "$ (pyenv init-)"
Fi

The function of this code is to indicate the location of the pyenv, so that you can run the pyenv command directly in the command line. It is saved in the ~/.BASHRC file to automatically take effect every time the user logs in.

So if you're running the order for the first time and you don't log off, this paragraph will not work, and we need to run the following order to make it effective:

SOURCE ~/.BASHRC installs Python and manages

See what versions of Python can be installed:

Pyenv Install--list

To install the 3.4.3 version of Python:

Pyenv Install 3.4.3

When you are finished installing, you can view the installation:

Pyenv versions

The results are as follows:

System
* 3.4.2 (set by/users/wxc/.pyenv/version)
3.4.3

* Represents the current Python version, and system represents the systems version.

Toggle Python version:

Pyenv Global 3.4.3

The results are as follows:

System
3.4.2
* 3.4.3 (set by/users/wxc/.pyenv/version)

You can see that the Python version has switched to 3.4.3 to perform the Python test successfully:
Python 3.4.3 (default, June 18 2015, 19:24:14)
[GCC 4.2.1 compatible Apple LLVM 5.1 (clang-503.0.40)] on Darwin
Type ' help ', ' copyright ', ' credits ' or ' license ' for the more information.
\>>>

If you want to cut back to the system version, enter:

PYENV Global System

If you want to uninstall a version of Python, enter:

Pyenv Uninstall 3.4.2

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.