包管理器負責包的安裝、更新以及自動安裝包的依賴。
Python作為主流的編程語言,在管理系統、大數據、人工智能等方面應用廣泛,同時,Python的版本也較多,相應的標準庫和第三方庫也非常多。
為更好地管理這些版本和庫,Python的包管理器有pip、conda、pipenv、poetry等。
軟件包中的軟件包數量龐大,版本多樣,需要使用pip、conda、pipenv、poetry等軟件源管理工具。
1. pip
pip是Python包的通用管理器,全稱為package installer for python,用來安裝、更新、卸載python的第三方庫。
pip的下載源為PyPi(Python Package Index,https://pypi.org/),當執行pip命令時,就會從https://pypi.org/下載庫,然后安裝到Python中($(python安裝目錄)\\lib\\site-packages)。
Ubuntu 18.04 默認安裝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
執行命令分別安裝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安裝成功后,便可以執行pip install 來安裝軟件包。
2. Conda
Pip是Python包管理器,Conda是軟件包管理器,適用于任何語言。
Conda在Anaconda/Miniconda已經打包好,后者提供Python + Conda + 軟件包,其中,Anaconda意為“蟒蛇”,提供了非常多的軟件包,用于科學計算、數據分析。
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。下載完成后,進行安裝。
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
-
人工智能
+關注
關注
1791文章
47183瀏覽量
238255 -
python
+關注
關注
56文章
4792瀏覽量
84627 -
大數據
+關注
關注
64文章
8882瀏覽量
137397
發布評論請先 登錄
相關推薦
評論