如何安装Anaconda及基本的使用请参考 macOS下Anaconda的安装及环境切换(Python2/Python3)
我在安装Anaconda的时候,软件自带的版本是Python3.6的,如果我现在需要使用Python2.7或者Python3.7,应该怎么操作呢?
如果我们在Anaconda Navigator控制台上做Create操作,环境是可以成功创建,但环境里面携带的包是非常少的。
所以可以参考如下方式进行Python版本修改。
1
| conda create -n python37 python=3.7 anaconda
|
如果conda的版本比较旧的话,会出现如下提示:
1 2 3 4 5 6 7
| ==> WARNING: A newer version of conda exists. <== current version: 4.6.2 latest version: 4.6.7
Please update conda by running
$ conda update -n base -c defaults conda
|
所以我们可以先执行命令
1
| conda update -n base -c defaults conda
|
然后再执行conda create命令
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| conda create -n python37 python=3.7 anaconda Collecting package metadata: done Solving environment: done
## Package Plan ##
environment location: /Users/simon/anaconda3/envs/python37
added / updated specs: - anaconda - python=3.7
The following packages will be downloaded:
package | build ---------------------------|----------------- mkl-2019.1 | 144 154.4 MB ------------------------------------------------------------ Total: 154.4 MB
The following NEW packages will be INSTALLED:
alabaster pkgs/main/osx-64::alabaster-0.7.12-py37_0 anaconda pkgs/main/osx-64::anaconda-2018.12-py37_0 ... ... Proceed ([y]/n)? y Downloading and Extracting Packages mkl-2019.1 | 154.4 MB | ###################################################################################################### | 100% Preparing transaction: done Verifying transaction: done Executing transaction: done # # To activate this environment, use: # > source activate python37 # # To deactivate an active environment, use: # > source deactivate #
|
按照上面的提示,我们可以执行如下命令激活或失效某个python环境。
1
| source activate python37
|