Otu esi etinye Python Pip na Ubuntu 20.04

PIP bụ njikwa ngwugwu ọkọlọtọ maka ịwụnye Python ngwugwu. Site na PIP, ị nwere ike depụta, chọọ na budata ka ịwụnye ngwugwu sitere na Python Package Index (PyPI). Ebu ụzọ tinye PIP na Python installer kemgbe ụdị 3.4 maka ntọhapụ Python 3 na 2.7.9 maka Python 2 ma jiri ọtụtụ ọrụ Python rụọ ọrụ nke ọma.

N'ime nkuzi a, ị ga-amụta otu esi etinye usoro PIP2 ma ọ bụ PIP3 Ubuntu 20.04.

Prerequisites

  • OS akwadoro: Ubuntu 20.04 - nhọrọ
  • Akaụntụ onye ọrụ: Akaụntụ onye ọrụ nwere sudo ma ọ bụ ohere mgbọrọgwụ.
  • Ngwungwu achọrọ: Python2 ma ọ bụ Python3.

Melite Sistemụ Ọrụ

Melite gi Ubuntu Sistemụ arụmọrụ iji hụ na ngwugwu niile dị adị adịla ugbu a:

sudo apt update && sudo apt upgrade -y

Nkuzi a ga-eji ya sudo iwu na na-eche na ị nwere ọnọdụ sudo.

Iji nyochaa ọkwa sudo na akaụntụ gị:

sudo whoami

Ihe atụ na-egosi ọkwa sudo:

[joshua@ubuntu ~]$ sudo whoami
root

 Ka ịtọlite ​​akaụntụ sudo dị adị ma ọ bụ ọhụrụ, gaa na nkuzi anyị na na-agbakwunye onye ọrụ na Sudoers na Ubuntu.

Iji mgbọrọgwụ akaụntụ, jiri iwu na-esonụ na paswọọdụ mgbọrọgwụ banye.

su

Advertisement


PIP2 vs PIP3

Maka ndị ọhụrụ na asụsụ mmemme Python kpam kpam, ị nwere ike ịnọ na-eche ihe dị iche n'etiti PIP2 na PIP3 bụ. Iji chịkọta ya, PIP2 bụ njikọ dị nro maka otu onye nrụnye na-agba ụdị Python ochie. PIP3 bụ ụdị pip emelitere nke ejiri maka ya Python 3+.

A na-atụ aro nke ukwuu iji Python 3 na PIP3, ma ị ga-emelite nke a ozugbo enwere ike.

Onye njikwa ngwugwu PIP2 ma ọ bụ PIP3 VS APT

Ajụjụ a na-ajụ mgbe niile ka m kwesịrị iji APT ma ọ bụ PIP. Nke a bụ nhọrọ nke onye ọrụ ọ bụla ga-emerịrị. APT na-adị ngwa ngwa mana ọ bụ ihe ochie karịa ebe a na-eji PIP budata ma wụnye ngwugwu ozugbo site na PyPI. Maka ndị na-amaghị, Python Software Foundation na-akwado PyPI, onye njikwa ngwugwu na-emekọ naanị ngwugwu Python nke na-emelite karịa nke Canonical kwadoro site na APT. Naanị ihe ndọghachi azụ nke iji PIP site na PyPI bụ na ngwugwu nwere ike iwe ogologo oge iji wụnye.


Advertisement


Wụnye Python 2 ma ọ bụ 3 na Ubuntu 20.04

Wụnye Eke Ọgba 2

Site na ndabara, Ubuntu nwere Python2, nke enwere ike itinye ya na ya Python ma ọ bụ Python2 iwu.

Iji tinye Python2, nke ga-eji PIP2 emechaa, jiri iwu a:

sudo apt install python -y

Ọzọ, gaba na Wụnye PIP wee wụnye ụdị kwekọrọ na nrụnye Python gị.

Wụnye Eke Ọgba 3

Iji tinye Python 3, nke ga-eji PIP3 emechaa, jiri ihe ndị a:

sudo apt install python3 -y

Ọzọ, gaba na Wụnye PIP wee wụnye ụdị kwekọrọ na nrụnye Python gị.

Wụnye PIP 2 ma ọ bụ 3 na Ubuntu 20.04

Wụnye PIP2

Iji wụnye PIP na Ubuntu 20.04, ị ga-achọ ijide n'aka na etinyere ebe nchekwa Eluigwe na Ala:

sudo add-apt-repository universe -y && sudo apt update

Iji wụnye PIP2, ị ga-achọ ibudata .py script dị ka ndị a:

curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py

Ugbu a, mee ihe .py edemede

sudo python2 get-pip.py

Ihe atụ nke ihe ndabere nke a ga-etinye:

Otu esi etinye Python Pip na Ubuntu 20.04

ụdị Y, wee pịa tinye igodo ịga n'ihu nwụnye.

Iji gosi ma arụnyere PIP2 nke ọma, mee ihe ndị a iwu ụdị:

pip2 --version

Ihe atụ mmepụta:

pip 20.3.4 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)

Wụnye PIP3

Iji wụnye PIP3 (maka Python 3+):

sudo apt install python3-pip 

Ihe atụ nke ihe ndabere nke a ga-etinye:

Otu esi etinye Python Pip na Ubuntu 20.04

Iji gosi ma arụnyere PIP3 nke ọma, mee ihe ndị a iwu ụdị:

pip3 --version 

Ihe atụ mmepụta:

spip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)

Advertisement


Otu esi eji PIP na Ubuntu 20.04

PIP nwere nnukwu ndepụta ngwugwu enwere ike ịwụnye, ụzọ dị mfe iji hụ ụfọdụ ihe dị bụ iji mee ndepụta iwu PIP na ịchọ. Iwu ndị a ga-arụ ọrụ na PIP na PIP3 na obere mgbanwe, n'ezie.

Nkuzi a ga-eji ụfọdụ uleles n'okpuru maka PIP3.

Nke mbụ, ka ịlele ndepụta nke iwu pip niile na nhọrọ, pịnye iwu a:

pip3 --help
Otu esi etinye Python Pip na Ubuntu 20.04

Ọmụmaatụ nke iji enyemaka pip3, ọmụmaatụ n'okpuru inweta enyemaka na nbudata:

pip3 download --help

Ihe atụ mmepụta:

Otu esi etinye Python Pip na Ubuntu 20.04

Ka ịdepụta ngwugwu dị maka ịwụnye na PIP3, jiri ihe ndị a:

pip3 list

Ihe atụ mmepụta:

Otu esi etinye Python Pip na Ubuntu 20.04

Ọ bụrụ na ịchọrọ iwetu ndepụta ahụ, jiri njirimara ọchụchọ dị ka ndị a:

pip3 search PACKAGE_NAME

Iji tinye PIP3 ngwugwu, jiri iwu a:

sudo pip3 install numpy

N'ihe atụ dị n'elu, nke Nọmba etinyere ngwugwu.

Ihe atụ mmepụta:

Otu esi etinye Python Pip na Ubuntu 20.04

Iji wepu ngwugwu PIP3, jiri iwu a:

sudo pip3 uninstall numpy

Ihe atụ mmepụta:

Otu esi etinye Python Pip na Ubuntu 20.04

ụdị Y, wee pịa tinye igodo iji mezue iwepụ.

Ihe atụ mmepụta:

Successfully uninstalled numpy-1.21.2

Otu esi ewepu PIP na Ubuntu 20.04

Iji wepu PIP na sistemụ Ubuntu gị, soro iwu ndị a dabere na ụdị ị rụnyere.

Iji wepu PIP:

sudo python -m pip uninstall pip

Ihe atụ mmepụta:

Otu esi etinye Python Pip na Ubuntu 20.04

ụdị Y, wee pịa Tinye igodo iji mezue iwepụ.

Ihe atụ mmepụta:

Successfully uninstalled pip-20.3.4

Iji wepu PIP3:

sudo apt autoremove python3-pip

Ihe atụ mmepụta:

Otu esi etinye Python Pip na Ubuntu 20.04

ụdị Y, wee pịa Tinye igodo iji mezue iwepụ.


Advertisement


Okwu na mmechi

N'ime nkuzi a, ị mụtala otu esi etinye PIP maka Python ma ọ bụ Python 3 wee chọọ, wụnye na wepu ngwugwu.

Iji chọpụta ozi ndị ọzọ na PIP, gaa na onye ọrụ gọọmentị akwụkwọ.

Idenye aha
Gwa nke
0 Comments
Inline nzaghachi
Lee echiche niile
0
Ga-ahụ n'anya gị echiche, biko okwu.x