Mac installation of pyenv and pyenv

Mac system comes with Python is 2.7.10, they need Python 3.x, this time need to install multiple systems in Python, but can not affect the system comes with Python, ie the need to implement the coexistence of multiple versions of Python, pyenv is such a Python version manager.

1. Install homebrew, by installing homebrew pyecharts, perform the following command to install homebrew

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

 Test whether the installation is successful, execution

brew -v

There are suggested the successful

Homebrew 2.1.4
Homebrew/homebrew-core (git revision c58dc; last commit 2019-06-05)

If homebrew already installed can ignore the first step.

2. Install pyenv

brew install pyenv

Check whether the installation is successful, execute pyenv -v

pyenv 1.2.11

Above prompted the version number indicates that the installation was successful

3. Check the python version installed

pyenv install --list

Lists all installed python versions, there are many, following a few simple column

Available versions:
  3.6.1
  3.6.2
  3.6.3
  3.6.4
  3.6.5
  3.6.6
  3.6.7
  3.6.8
  3.7.0
  3.7-dev
  3.7.1
  3.7.2
  3.7.3

4. certain versions of python

pyenv install <version> 

For example install version 3.6.4 by executing the command

pyenv install 3.6.4 -v

5. Review pyenv installed version

pyenv versions

Lists all the python version is already installed, as follows

system
* 3.6.4 (set by /Users/kumufengchun/Documents/python/.python-version)

Lists two, one is the system comes with a newly installed version is 3.6.4

6. Edit the .bash_profile

It found that the use of the time after the installation or system versions, you need to edit the file .bash_profile

Switch to the root directory

cd ~

.Bash_profile file open, if not the file, create a new, enter the following code in the file

if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi

.bash_profile content Save, and then enter the following command, using the updated after

source .bash_profile

7. Review the current python version

pyenv version
3.6.4 (set by /Users/kumufengchun/Documents/python/.python-version)

  Behind parentheses indicate the contents of this version is activated by Which pathway (global, local, shell)

8. Switch Version

[root@localhost ~]# pyenv global 3.6.4
[root@localhost ~]# pyenv version
3.6.4 (set by /root/.pyenv/version)

The need to update the database 9. After the installation is complete

pyenv rehash

10. Uninstall python 3.4.0 version

pyenv uninstall 3.4.0

11. The setup for the local version, the version number is written by the presently .python-version files in the directory

 # Create a local directory ops, after performing pyenv local 3.5.3, only the directory is version 3.5.3, another directory using the default versions.

[root@localhost ~]# python -V
Python 3.5.1
[root@localhost ~]# pyenv versions
  system
* 3.5.1 (set by /root/.pyenv/version)
  3.5.3
[root@localhost ~]#
[root@localhost ~]# mkdir ops
[root@localhost ~]# cd ops/
[root@localhost ops]# pyenv local 3.5.3
[root@localhost ops]# python -V
Python 3.5.3
[root@localhost ops]# cd ..
[root@localhost ~]# python -V
Python 3.5.1

  

Guess you like

Origin www.cnblogs.com/kumufengchun/p/10986498.html