包管理器負(fù)責(zé)包的安裝、更新以及自動安裝包的依賴。
Python作為主流的編程語言,在管理系統(tǒng)、大數(shù)據(jù)、人工智能等方面應(yīng)用廣泛,同時,Python的版本也較多,相應(yīng)的標(biāo)準(zhǔn)庫和第三方庫也非常多。
為更好地管理這些版本和庫,Python的包管理器有pip、conda、pipenv、poetry等。
軟件包中的軟件包數(shù)量龐大,版本多樣,需要使用pip、conda、pipenv、poetry等軟件源管理工具。
1. pip
pip是Python包的通用管理器,全稱為package installer for python,用來安裝、更新、卸載python的第三方庫。
pip的下載源為PyPi(Python Package Index,https://pypi.org/),當(dāng)執(zhí)行pip命令時,就會從https://pypi.org/下載庫,然后安裝到Python中($(python安裝目錄)\\lib\\site-packages)。
Ubuntu 18.04 默認(rèn)安裝Python2和Python3,但未安裝pip和pip3。
root@linux:~# python --version
Python 3.6.9
root@linux:~# python3 --version
Python 3.6.9
root@linux:~# pip3 --version
Command 'pip3' not found, but can be installed with:
apt install python3-pip
root@linux:~# pip --version
Command 'pip' not found, but can be installed with:
apt install python-pip
執(zhí)行命令分別安裝pip和pip3。
apt install python-pip
apt install python3-pip
安裝后,可查看具體版本信息
root@linux:~# pip3 --version
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)
pip安裝成功后,便可以執(zhí)行pip install 來安裝軟件包。
2. Conda
Pip是Python包管理器,Conda是軟件包管理器,適用于任何語言。
Conda在Anaconda/Miniconda已經(jīng)打包好,后者提供Python + Conda + 軟件包,其中,Anaconda意為“蟒蛇”,提供了非常多的軟件包,用于科學(xué)計算、數(shù)據(jù)分析。
Anaconda源為https://www.anaconda.com/,也可以使用清華源https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/。
Miniconda源為https://docs.conda.io/en/latest/miniconda.html
Anaconda的安裝,下載鏈接:
https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/
......
Anaconda3-2021.05-Linux-aarch64.sh412.6 MiB2021-05-14 11:33
Anaconda3-2021.05-MacOSX-x86_64.pkg440.3 MiB2021-05-14 11:33
Anaconda3-2021.05-Linux-x86_64.sh544.4 MiB2021-05-14 11:33
Anaconda3-2021.05-Linux-s390x.sh291.7 MiB2021-05-14 11:33
Anaconda3-2021.05-MacOSX-x86_64.sh432.7 MiB2021-05-14 11:34
Anaconda3-2021.05-Windows-x86.exe408.5 MiB2021-05-14 11:34
Anaconda3-2021.05-Windows-x86_64.exe477.2 MiB2021-05-14 11:34
Anaconda3-2021.11-Linux-aarch64.sh487.7 MiB2021-11-18 02:14
Anaconda3-2021.11-Linux-ppc64le.sh254.9 MiB2021-11-18 02:14
Anaconda3-2021.11-Linux-s390x.sh241.7 MiB2021-11-18 02:14
Anaconda3-2021.11-Linux-x86_64.sh580.5 MiB2021-11-18 02:14
Anaconda3-2021.11-MacOSX-x86_64.pkg515.1 MiB2021-11-18 02:14
Anaconda3-2021.11-MacOSX-x86_64.sh508.4 MiB2021-11-18 02:14
Anaconda3-2021.11-Windows-x86.exe404.1 MiB2021-11-18 02:14
Anaconda3-2021.11-Windows-x86_64.exe510.3 MiB2021-11-18 02:14
選擇Anaconda3-2021.05-Linux-x86_64.sh。下載完成后,進(jìn)行安裝。
root@linux:/home# ls
Anaconda3-2021.05-Linux-x86_64.sh ftp linux
root@linux:/home# Anaconda3-2021.05-Linux-x86_64.sh
Anaconda3-2021.05-Linux-x86_64.sh: command not found
root@linux:/home# bash Anaconda3-2021.05-Linux-x86_64.sh
Welcome to Anaconda3 2021.05
In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue
>>>
===================================
End User License Agreement - Anaconda Individual Edition
===================================
Copyright 2015-2021, Anaconda, Inc.
All rights reserved under the 3-clause BSD License:
......
Do you accept the license terms? [yes|no]
Please answer 'yes' or 'no':'
>>> yes
Anaconda3 will now be installed into this location:
/root/anaconda3
- Press ENTER to confirm the location
- Press CTRL-C to abort the installation
- Or specify a different location below
[/root/anaconda3] >>>
Preparing transaction: done
Executing transaction: done
installation finished.
Do you wish the installer to initialize Anaconda3
by running conda init? [yes|no]
[no] >>> yes
......
conda config --set auto_activate_base false
Thank you for installing Anaconda3!
===========================================================================
Working with Python and Jupyter notebooks is a breeze with PyCharm Pro,
designed to be used with Anaconda. Download now and have the best data
tools at your fingertips.
PyCharm Pro for Anaconda is available at: https://www.anaconda.com/pycharm
(base) root@linux:/home# python
Python 3.8.8 (default, Apr 13 2021, 19:58:26)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
(base) root@linux:/home# conda --version
conda 4.10.1
(base) root@linux:/home# conda env list
# conda environments:
#
base * /root/anaconda3
-
人工智能
+關(guān)注
關(guān)注
1791文章
47282瀏覽量
238534 -
python
+關(guān)注
關(guān)注
56文章
4797瀏覽量
84694 -
大數(shù)據(jù)
+關(guān)注
關(guān)注
64文章
8890瀏覽量
137449
發(fā)布評論請先 登錄
相關(guān)推薦
評論