如何在Anaconda中安装Python库?

1打开Anaconda提示符,检查库是否已安装。

 如何在Anaconda中安装Python库?_第1张图片

打开Anaconda提示符,检查库是否已安装。

(base) C:\Users\lilywan>python
Python 3.10.9 | packaged by Anaconda, Inc. | (main, Mar  1 2023, 18:18:15) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> exit()

 由于不存在名为numpy的模块,我们将运行以下命令来安装numpy。

(base) C:\Users\lilywan>python
Python 3.10.9 | packaged by Anaconda, Inc. | (main, Mar  1 2023, 18:18:15) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy

>>> exit()
(base) C:\Users\lilywan>conda install numpy
Collecting package metadata (current_repodata.json): done
Solving environment: done

完成安装后,您将看到如图所示的窗口。

(base) C:\Users\lilywan>conda install numpy
Collecting package metadata (current_repodata.json): done
Solving environment: done


==> WARNING: A newer version of conda exists. <==
  current version: 23.3.1
  latest version: 23.5.0

Please update conda by running

    $ conda update -n base -c defaults conda

Or to minimize the number of packages updated during conda update use

     conda install conda=23.5.0



## Package Plan ##

  environment location: C:\Users\lilywan\AppData\Local\Programs\Python\Python311\Anaconda

  added / updated specs:
    - numpy


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    certifi-2023.5.7           |  py310haa95532_0         153 KB
    openssl-1.1.1u             |       h2bbff1b_0         5.5 MB
    ------------------------------------------------------------
                                           Total:         5.6 MB

The following packages will be UPDATED:

  ca-certificates                     2023.01.10-haa95532_0 --> 2023.05.30-haa95532_0
  certifi                         2022.12.7-py310haa95532_0 --> 2023.5.7-py310haa95532_0
  openssl                                 1.1.1t-h2bbff1b_0 --> 1.1.1u-h2bbff1b_0

一旦安装了库,只需再次尝试导入模块即可确保安全。

                                           Total:         5.6 MB

The following packages will be UPDATED:

  ca-certificates                     2023.01.10-haa95532_0 --> 2023.05.30-haa95532_0
  certifi                         2022.12.7-py310haa95532_0 --> 2023.5.7-py310haa95532_0
  openssl                                 1.1.1t-h2bbff1b_0 --> 1.1.1u-h2bbff1b_0


Proceed ([y]/n)? y


Downloading and Extracting Packages

Preparing transaction: done
Verifying transaction: done
Executing transaction: done

(base) C:\Users\lilywan>python
Python 3.10.9 | packaged by Anaconda, Inc. | (main, Mar  1 2023, 18:18:15) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>>

如您所见,我们在开始时没有遇到任何错误,所以这就是我们如何在Python中安装各种库的方法。

你可能感兴趣的:(python,开发语言)