Maitiro ekushandisa pip muPython: gwara rakazara

  • pip inoita kuti zvive nyore kuisa uye kubata mapakeji muPython.
  • Masisitimu anoshanda akasiyana anoda matanho chaiwo ekuisa pip.
  • Virtual nharaunda dzinokutendera kuti uzvitsaurire kutsamira kweprojekiti muPython.

pip mu python

Python Ndiyo imwe yemitauro yakawanda uye yakakurumbira yekuronga mitauro nekuda kwekuverenga kwayo uye yakakura nharaunda yevagadziri. Nekudaro, chii chinopa simba Python kugona kwayo kushanda nayo modules uye mapakeji, ari mamwe maraibhurari anowedzera mashandiro ayo. Apa ndipo pazvinobuda. Pip, akakosha pasuru maneja kune chero mugadziri anoshanda nePython.

Muchikamu chino, tichaongorora zvakadzama kuti pip chii, sei kuisa uye kuishandisa zvinobudirira, pamwe nekukupa. mazano anoshanda kugadzirisa mapakeji uye kugadzirisa matambudziko akajairika. Kana iwe usati wajaira pip kana kuda kuwedzera ruzivo rwako, sosi iyi ndiyo ichave yako yechokwadi gwara.

Chii chinonzi pip uye nei uchifanira kuishandisa?

Pip chishandiso chemutsetse wekuraira chinoshandiswa kuisa, kugadzirisa, uye kubata maraibhurari muPython. Zita racho rinobva pashoko rokuti “Pip Inoisa Mapakeji”. Nepip, unogona kuwana zviuru zvemapakeji anowanikwa mune yepamutemo Python repository, inozivikanwa se PyPI (Python Package Index).

Imwe yemabhenefiti makuru epip ndeyekuti inorerutsa zvinoshamisa maitiro ekuisa uye kugadzirisa imwe software yePython. Panzvimbo yekurodha pasi uye kugadzirisa maraibhurari pamaoko, pip inoita zvese basa rinorema nokuda kwako, kuchengetedza nguva uye zvikanganiso zvisingakoshi.

Nzira yekuziva sei kana iwe uine pip yakaiswa

Usati washandisa pip, unofanirwa kuve nechokwadi kuti yakaiswa pane yako system. Izvi zvinogona kusimbiswa zviri nyore nekuvhura terminal uye nekumhanyisa unotevera kuraira:

pip --version

Kana iwe ukaona ruzivo nezve vhezheni yepip, wagadzirira kuishandisa. Kana zvisina kudaro, iwe uchada kuiisa.

Kuisa pip pane akasiyana masisitimu anoshanda

Iyo pip yekuisa maitiro inosiyana zvichienderana neiyo inoshanda sisitimu, asi kazhinji iri nyore.

Pamawindo

  1. Dhaunirodha chinyorwa chekuisa get-pip.py kubva Iyi link.
  2. Vhura iyo terminal (CMD kana PowerShell) uye famba uchienda kudhairekitori kwawakadhawunirodha faira.
  3. Mhanya unotevera kuraira: python get-pip.py.

Yeuka kuti unofanira kuva nazvo Python yakamboiswa pane yako system.

PaMac

Iwo masisitimu macOS Mazuva ano anowanzo sanganisira pip by default. Nekudaro, iwe unogona kuimisa nemaoko nemurairo unotevera:

sudo easy_install pip

Imwe sarudzo inokurudzirwa ndeyekuisa Python kuburikidza Homebrew, maneja wepakeji ye macOS. Simply run:

brew install python

PaLinux

Yakawanda yeLinux kugovera inosanganisira Python uye pip mune yavo mapakeji repositori. Iyo mirairo inosiyana zvishoma zvichienderana nekugovera kwako pasuru manejimendi:

  • Zvekugovera-kwakavakirwa paDebian (seUbuntu): sudo apt install python3-pip
  • Zve Fedora: sudo dnf install python3-pip
  • YeArch Linux: sudo pacman -S python-pip
  • ZvekuvhuraSUSE: sudo zypper install python3-pip

pip installation

Basic kushandiswa kwepip

Kana yangoiswa, unogona kutanga explore izvo pip inogona kuita. Heino pfupiso yemirairo inonyanya kukosha:

Isa mapakeji

Kuisa raibhurari, shandisa murairo:

pip install nombre_del_paquete

Somuenzaniso, kuisa raibhurari chikumbiro, unogona kunyora:

pip install requests

Gadziridza mapakeji

Kana iwe uchida kugadzirisa pasuru kune yazvino vhezheni, shandisa:

pip install --upgrade nombre_del_paquete

Somuenzaniso:

pip install --upgrade requests

Uninstall mapakeji

Kuti ubvise pasuru yausingachada, shandisa:

pip uninstall nombre_del_paquete

Somuenzaniso:

pip uninstall requests

Rondedzero yakaiswa mapakeji

Kuti uone mapakeji ese akaiswa munzvimbo yako, mhanya:

pip list

Kuiswa kubva kuzvinodiwa.txt faira

Mumapurojekiti ekubatana, zvakajairika kushandisa faira inonzi zvinodiwa.txt iyo ine runyoro rwezvinoda kutsamira. Kuaisa ese kamwechete, shandisa:

pip install -r requirements.txt

Gadzira uye gadzirisa chaiwo nharaunda

A virtual environment inokubvumira isolate kutsamira kwepurojekiti kuitira kuti isakanganise vamwe. Unogona kuigadzira uchishandisa chishandiso venv, iyo inosanganisirwa muPython kutanga neshanduro 3.3:

python -m venv nombre_entorno

Kuti uite izvozvo:

source nombre_entorno/bin/activate (paLinux uye Mac)
nombre_entorno\Scripts\activate (paWindows)

Ipapo chero kuiswa nepip kunogumira kune iyo nharaunda chaiyo kuti waita activated.

Kazhinji kugadzirisa matambudziko

Kana ukasangana nezvikanganiso uchishandisa pip, heino mhinduro dzinokurumidza kumatambudziko akajairika:

  • Mvumo isina kukwana: Zvishandiso sudo paLinux/Mac kana mhanyisa terminal semaneja paWindows.
  • Pakeji kutadza kumisa: Ita shuwa iyo system dependencies Vanogadziridzwa.
  • Matambudziko neshanduro: Shandisa pip freeze kunyora mapakeji neshanduro dzazvino.

Mastering pip uye kushanda kwayo kwakakosha pakugadzirisa basa rako nePython. Kunyangwe zvingaite sezvinotyisa pakutanga, kana uchinge wajairana nemirairo yayo yekutanga, iwe uchaona kuti icho chinofanirwa-kuva nechishandiso mune yako yekuvandudza arsenal.


Iva wekutanga kutaura

Siya yako yekutaura

Your kero e havazobvumirwi ichibudiswa. Raida minda anozivikanwa ne *

*

*

  1. Inotarisira iyo data: Miguel Ángel Gatón
  2. Chinangwa cheiyo data: Kudzora SPAM, manejimendi manejimendi.
  3. Legitimation: Kubvuma kwako
  4. Kutaurirana kwedata
  5. Dhata yekuchengetedza: Dhatabhesi inobatwa neOccentus Networks (EU)
  6. Kodzero: Panguva ipi neipi iwe unogona kudzora, kupora uye kudzima ruzivo rwako