Anaconda学习使用

16 篇文章 0 订阅

https://conda.io/docs/user-guide/getting-started.html

https://docs.anaconda.com/anaconda/install/windows/

install windows (不添加环境变量,使用anaconda开始菜单中的命令行)

Choose whether to add Anaconda to your PATH environment variable. We recommend not adding Anaconda to the PATH environment variable, since this can interfere with other software. Instead, use Anaconda software by opening Anaconda Navigator or the Anaconda Prompt from the Start Menu.

Starting conda

Windows

  • From the Start menu, search for and open “Anaconda Prompt”.

../_images/anaconda-prompt.png

 

On Windows, all commands below are typed into the Anaconda Prompt window.

MacOS

  • Open Launchpad, then click the Terminal icon.

On macOS, all commands below are typed into the Terminal window.

Linux

  • Open a Terminal window.

On Linux, all commands below are typed into the Terminal window.

Managing conda

Verify that conda is installed and running on your system by typing:

conda --version

Conda displays the number of the version that you have installed. You do not need to navigate to the Anaconda directory.

EXAMPLE: conda 4.4.9

NOTE: If you get an error message, make sure you closed and re-opened the Terminal window after installing, or do it now. Then verify that you are logged into the same user account that you used to install Anaconda or Miniconda.

Update conda to the current version. Type the following:

conda update conda

Conda compares versions and then displays what is available to install.

If a newer version of conda is available, type y to update:

Proceed ([y]/n)? y

TIP: We recommend that you always keep conda updated to the latest version.

Managing Environments配置环境变量

Conda allows you to to create separate environments containing files, packages and their dependencies that will not interact with other environments.

When you begin using conda, you already have a default environment named base. You don’t want to put programs into your base environment, though. Create separate environments to keep your programs isolated from each other.

  1. Create a new environment and install a package in it.

    We will name the environment snowflakes and install the package BioPython. At the Anaconda Prompt or in your Terminal window, type the following:

    conda create --name snowflakes biopython
    

    Conda checks to see what additional packages (“dependencies”) Biopython will need, and asks if you want to proceed:

    Proceed ([y]/n)? y
    

    Type “y” and press Enter to proceed.

  2. To use, or “activate” the new environment, type the following:

    • Windows: activate snowflakes
    • Linux and macOS: source activate snowflakes

    Now that you are in your snowflakes environment, any conda commands you type will go to that environment until you deactivate it.

  3. To see a list of all your environments, type:

    conda info --envs
    

    A list of environments appears, similar to the following:

    conda environments:
    
        base           /home/username/Anaconda3
        snowflakes   * /home/username/Anaconda3/envs/snowflakes
    

    TIP: The active environment is the one with an asterisk (*).

  4. Change your current environment back to the default (base):

    • Windows: deactivate
    • Linux, macOS: source deactivate

    TIP: When the environment is deactivated, its name is no longer shown in your prompt, and the asterisk (*) returns to base. To verify, you can repeat the conda info --envs command.

Managing Python

When you create a new environment, conda installs the same Python version you used when you downloaded and installed Anaconda. If you want to use a different version of Python, for example Python 3.5, simply create a new environment and specify the version of Python that you want.

  1. Create a new environment named “snakes” that contains Python 3.5:

    conda create --name snakes python=3.5
    

    When conda asks if you want to proceed, type “y” and press Enter.

  2. Activate the new environment:

    • Windows: activate snakes
    • Linux, macOS: source activate snakes
  3. Verify that the snakes environment has been added and is active:

    conda info --envs
    

    Conda displays the list of all environments with an asterisk (*) after the name of the active environment:

    # conda environments:
    #
    base                     /home/username/anaconda3
    snakes                *  /home/username/anaconda3/envs/snakes
    snowflakes               /home/username/anaconda3/envs/snowflakes
    

    The active environment is also displayed in front of your prompt in (parentheses) or [brackets] like this:

    (snakes) $
    
  4. Verify which version of Python is in your current environment:

    python --version
    
  5. Deactivate the snakes environment and return to base environment:

    • Windows: deactivate
    • Linux, macOS: source deactivate

Managing packages

In this section, you check which packages you have installed, check which are available and look for a specific package and install it.

  1. To find a package you have already installed, first activate the environment you want to search. Look above for the commands to activate your snakes environment.

  2. Check to see if a package you have not installed named “beautifulsoup4” is available from the Anaconda repository (must be connected to the Internet):

    conda search beautifulsoup4
    

    Conda displays a list of all packages with that name on the Anaconda repository, so we know it is available.

  3. Install this package into the current environment:

    conda install beautifulsoup4
    
  4. Check to see if the newly installed program is in this environment:

    conda list
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值