Conda入门指南

2,096次阅读
没有评论

Managing packages

Before you begin, you should have installed Miniconda or Anaconda, and gone through the previous Managing environments section. That means you have already installed a few packages when you created a new environment.

NOTE: There are many options available for each of these commands. See the Command reference for more detail.

List all packages

List all of your packages in the active environment:

<span class="n">conda</span> <span class="nb">list</span>

To list all of your packages installed into a non-active environment named snowflakes:

<span class="n">conda</span> <span class="nb">list</span> <span class="o">-</span><span class="n">n</span> <span class="n">snowflakes</span>

Search for a package

To see if a specific package is available for conda to install:

<span class="n">conda</span> <span class="n">search</span> <span class="n">beautiful</span><span class="o">-</span><span class="n">soup</span>

This displays the package name, so we know it is available.

Install a package

Install a package such as “Beautiful Soup” into the current environment, using conda install as follows:

<span class="n">conda</span> <span class="n">install</span> <span class="o">--</span><span class="n">name</span> <span class="n">bunnies</span> <span class="n">beautiful</span><span class="o">-</span><span class="n">soup</span>

NOTE: If you do not specify the name of the environment where you want it installed (–name bunnies) it will install in the current environment.

Activate the bunnies environment, and do a conda list to see the new program installed:

Linux, OS X: source activate bunnies Windows: activate bunnies

All: conda list

NOTE: Installing a commercial package (such as IOPro) is the same as installing any other package: conda install --name bunnies iopro

Install a package from Anaconda.org

For packages that are not available using conda install, we can look in the repository Anaconda.org. Anaconda.org, formerly Binstar.org, is a package management service for both public and private package repositories. Anaconda.org is a Continuum Analytics product, just like Anaconda and Miniconda.

In a browser, go to http://anaconda.org. To find the package named “bottleneck” enter that search term in the top left box named “Search Packages.”

Find the package you want and click to go to the detail page. There you will see the name of the channel – in this case it is the “pandas” channel.

Now that you know the channel name, you can use the conda install command to get it:

<span class="n">conda</span> <span class="n">install</span> <span class="o">-</span><span class="n">c</span> <span class="n">pandas</span> <span class="n">bottleneck</span>

That means “Conda install the Bottleneck package from the Pandas channel on Anaconda.org.”

The package will install.

Check to see that the package is now installed:

<span class="n">conda</span> <span class="nb">list</span>

You will see a list of packages, including Bottleneck.

NOTE: Conda can install packages from multiple channels.

Install non-conda packages

If a package is not available from conda or Anaconda.org, you may be able to find and install the package with another package manager like pip.

NOTE: Both pip and conda are already included in Anaconda and Miniconda, so you do not need to install them separately.

NOTE: Conda environments replace virtualenv so there’s no need to activate a virtualenv before using pip.

Activate the environment where you want to put the program, then pip install a program named “See”:

Linux, OS X: source activate bunnies

Windows: activate bunnies

All: pip install see

Check to see that the See package was installed by pip:

<span class="n">conda</span> <span class="nb">list</span>

Install a commercial package

Installing commercial packages is the same as installing any other package with conda. So as an example, let’s install and then delete a free trial of one of Continuum’s commercial packages IOPro, which can speed up your Python processing:

<span class="n">conda</span> <span class="n">install</span> <span class="n">iopro</span>

TIP: Except for academic use, this free trial expires after 30 days.

You can now install and verify any package you want using conda, whether using the conda command, downloading from Anaconda.org, or using pip install, and whether open source or commercial.

Package update

You can check to see if a new update is available with the conda update command. If conda tells you an update is available, you can then choose whether or not to install it.

Use the conda update command to update a specific package:

<span class="n">conda</span> <span class="n">update</span> <span class="n">biopython</span>

You can use the conda update command to update conda itself:

<span class="n">conda</span> <span class="n">update</span> <span class="n">conda</span>

You can also update Python with the update command:

<span class="n">conda</span> <span class="n">update</span> <span class="n">python</span>

NOTE: Conda will update to the highest version in its series, so Python 2.7 will update to the highest available in the 2.x series, and 3.5 will update to the highest available in the 3.x series.

Regardless of what package you are updating, conda will compare versions, then let you know what is available to install. If none are available, conda will reply “All requested packages are already installed.”

If a newer version of your package is available, and you wish to update it, type Y to update:

Proceed ([y]/n)? y

Type “y” for yes.

Package remove

If you decide not to continue using a package, for example, the commercial package IOPro, you can remove it from the bunnies environment with:

<span class="n">conda</span> <span class="n">remove</span> <span class="o">--</span><span class="n">name</span> <span class="n">bunnies</span> <span class="n">iopro</span>

Confirm that the package has been removed:

<span class="n">conda</span> <span class="nb">list</span>
admin
版权声明:本站原创文章,由admin2017-02-13发表,共计4157字。
转载提示:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
评论(没有评论)