cndavy

导航

 

Conda 简单使用

conda是anaconda里自带的一个工具,结合了pip、virtualENV等多个工具,可以方便的管理python环境和包!

用conda创建一个名叫python2的版本为python2.7的环境。

conda create -n python2 python=2.7
这样就会在Anaconda安装目录下的envs目录下创建python2这个目录。

 

 

向其中安装扩展可以:

直接用 conda install 并用 -n 指明安装到的环境,这里自然就是 python2 。
像 virtualenv 那样,先activate,然后在虚拟环境中安装。
这里突然有一个问题,怎样在IDE中使用创建出来的环境?如果是PyCharm等IDE,直接设置Python安装目录就可以了。那spyder呢?其实spyder就是一个Python的扩展,你需要在虚拟环境中也装一个spyder。

 

$ conda create -n py33test anaconda=1.9 python=3.3 numpy=1.8

$ source activate py33test

Single libraries and packages can be installed using the  conda install command, either
in the general  Anaconda installation:
$ conda install scipy
or for a specific environment, as in:
$ conda install -n py33test scipy
Here,  py33test is the environment we created before. Similarly, you can update single
packages easily:
$ conda update pandas
The packages to download and link depend on the respective version of the package that is
installed. These can be very few to numerous, e.g., when a package has a number of
www.it-ebooks.info
dependencies for which no current version is installed. For our newly created
environment, the updating would take the form:
$ conda update -n py33test pandas
Finally,  conda makes it easy to remove packages with the  remove command from the main
installation or a specific environment. The basic usage is:
$ conda remove scipy
For an environment it is:
$ conda remove -n py33test scipy
Since the removal is a somewhat “final” operation, you might want to dry run the
command:
$ conda remove —dry-run -n py33test scipy
If you are sure, you can go ahead with the actual removal. To get back to the original
Python and  Anaconda version, deactivate the environment:
$ source deactivate
Finally, we can clean up the whole environment by use of  remove with the option  —all :
$ conda remove —all -n py33test
The package manager  conda makes  Python deployment quite convenient. Apart from the
basic functionalities illustrated in this section, there are also a number of more advanced
features available. Detailed documentation is found at http://conda.pydata.org/docs/.

posted on 2017-03-21 16:40  cndavy  阅读(708)  评论(0编辑  收藏  举报