5、【Python】Mac安装管理多个版本的python及numpy/pandas/scipy/matplotlib的安装
2018-11-20 21:47
711 查看
一、问题由来
Mac OS 自带的python是2.x,自己开发需要python 3.x,但担心卸载系统自带的python 2.x会造成系统的不稳定,因此,需要在系统中额外安装python 3.x。pyenv就是这样一个python版本管理器。
二、安装过程
1、安装homebrew
2、安装 pyenv
使用homebrew安装pyenv,Mac下再安装了homebrew后,可以使用homebrew安装pyenv。
brew update brew install pyenv brew upgrade pyenv #之后如果需要更新pyenv
在安装成功之后,需要在 .bashrc 或 .bash_profile 中添加一下几条语句来开启自动补全功能。
export PATH = "$HOME/.pyenv/bin:$PATH" eval "$(pyenv int -)" eval "$(pyenv virtualenv-init -)"
注意:如果在/home/usrername/目录下没有找到 .bashrc 或 .bash_profile 文件,则自己新建一个并在其中添加上面的内容。
3、pyenv常用命令
使用pyenv commands可以查看所有的pyenv命令。
(1) 查看已安装的python版本
$ pyenv versions system * 3.6.4 (set by /Users/username/.pyenv/version)
(2)查看可安装的python版本
$ pyenv install -l Available versions: 2.1.3 2.2.3 2.3.7 2.4 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.5 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.6.6 2.6.7 2.6.8 2.6.9 2.7-dev 2.7 2.7.1 2.7.2 2.7.3 …………
(3) 安装python
$ pyenv install <version> #version为版本号
(4) python 版本管理
pyenv global <version> # 全局设置python版本为指定版本,设置全局的 Python 版本,通过将版本号写入 ~/.pyenv/version 文件的方式。 pyenv local <version> # 设置当前路径下python版本为指定版本,设置 Python 本地版本,通过将版本号写入当前目录下的 .python-version 文件的方式。通过这种方式设置的 Python 版本优先级较 global 高。 pyenv shell <version> # 设置当前shell窗口使用的python版本为指定版本,设置面向 shell 的 Python 版本,通过设置当前 shell 的 PYENV_VERSION 环境变量的方式。这个版本的优先级比 local 和 global 都要高。–unset 参数可以用于取消当前 shell 设定的版本。
使用pyenv切换python版本之后可以通过which python 或者 python --version来查看是否生效。
(5) python 卸载
pyenv install <version> #安装版本号为<version>的python pyenv uninstall <version> #卸载版本号为<version>的python
更多详情参见:https://www.jianshu.com/p/2b0b652eaa50
三、numpy/pandas/scipy/matplotlib的安装
如果你安装使用的是python 3.3及以上的版本,这些版本都内置了pip包管理器,你可以使用pip简单快速的安装numpy/pandas/scipy/matplotlib等库。
sudo pip install numpy sudo pip install pandas sudo pip install scipy sudo pip install matplotlib阅读更多
相关文章推荐
- 学习Python数据分析(1)----numpy,Pandas,matplotlib,scipy 的安装
- python Numpy,SciPy,MatplotLib,pandas安装流程
- windows 安装python3.6(numpy,scipy,pandas,matplotlib,scikit-learn)
- Python模块简介及安装 [numpy,pandas,matplotlib,scipy,statsmodels,Gensim,sklearn,keras]
- windows安装python+numpy+scipy+matplotlib+pandas+beautifulsoup
- windows 安装python3.6(numpy,scipy,pandas,matplotlib,scikit-learn)
- windows 安装python3.6(numpy,scipy,pandas,matplotlib,scikit-learn)
- Python 之 安装 scipy,numpy,matplotlib,pandas
- windows 安装python3.6(numpy,scipy,pandas,matplotlib,scikit-learn)
- python3.5下安装numpy,scipy,sklearn,pandas,matplotlib,jieba,requests
- Python3.5.4对应版本matplotlib的安装过程(含NumPy&SciPy)
- windows 安装python3.6(numpy,scipy,pandas,matplotlib,scikit-learn)
- Windows64位下各版本Python安装numpy,SciPy,matplotlib,Ipython模块
- python3.6中安装numpy,pandas,scipy,scikit_learn,matplotlib等数据分析工具
- 如何在Linux系统Ubuntu版本下安装Python开发包NumPy、Matplotlib、SciPy
- 【编程语言】Python 使用包管理工具pip安装模块numpy、scipy、matplotlib以及scikit-learn CentOS 7
- windows 安装python3.6(numpy,scipy,pandas,matplotlib,scikit-learn)
- python3.6下安装(numpy,scipy,pandas,matplotlib,scikit-learn)
- Ubuntu16.04安装Python的数据分析库numpy,pandas,scipy,matplotlib
- Windos7(32位)安装Python2.7,再加上numpy、scipy、Matplotlib、Ipython、pandas