Pip (Python): verschil tussen versies

Uit De Vliegende Brigade
Naar navigatie springen Naar zoeken springen
 
(27 tussenliggende versies door dezelfde gebruiker niet weergegeven)
Regel 1: Regel 1:
''Pip'' is een Python ''package manager'' (of zoiets):
+
''Pip'' is de officiële Python ''package manager''.
 +
 
 +
Dit artikel stamt uit 2018. Oude zooi (inclusief alles rondom Python2) heb ik in dec. 2020 verwijderd. Zie ''Geschiedenis weergeven'' als je dat toch nodig hebt. Dit artikel heeft uitsluitend betrekking op Python3.
 +
 
 +
== Installatie ==
 +
 
 +
Dec. 2020, Linux Mint - Moeiteloos:
 +
 
 +
<pre>
 +
sudo apt install python3-pip
 +
</pre>
 +
 
 +
Testen:
  
 
<pre>
 
<pre>
 +
> pip
 +
 +
bash: pip: command not found
 +
 +
> pip3
 +
 
Usage:   
 
Usage:   
   pip <command> [options]
+
   pip3 <command> [options]
 +
  ...
 +
</pre>
  
Commands:
+
== Installatie van packages ==
  install                    Install packages.
 
  download                    Download packages.
 
  uninstall                  Uninstall packages.
 
  freeze                      Output installed packages in requirements format.
 
  list                        List installed packages.
 
  show                        Show information about installed packages.
 
  check                      Verify installed packages have compatible dependencies.
 
  config                      Manage local and global configuration.
 
  search                      Search PyPI for packages.
 
  wheel                      Build wheels from your requirements.
 
  hash                        Compute hashes of package archives.
 
  completion                  A helper command used for command completion.
 
  help                        Show help for commands.
 
  
General Options:
+
Bv.:
  -h, --help                  Show help.
+
 
  --isolated                  Run pip in an isolated mode, ignoring environment variables
+
<pre>
                              and user configuration.
+
pip3 install pymysql
  -v, --verbose              Give more output. Option is additive, and can be used up
 
                              to 3 times.
 
  -V, --version              Show version and exit.
 
  -q, --quiet                Give less output. Option is additive, and can be used up
 
                              to 3 times
 
                              (corresponding to WARNING, ERROR, and CRITICAL logging levels).
 
  --log <path>                Path to a verbose appending log.
 
  --proxy <proxy>            Specify a proxy in the form [user:passwd@]proxy.server:port.
 
  --retries <retries>        Maximum number of retries each connection should attempt
 
                              (default 5 times).
 
  --timeout <sec>            Set the socket timeout (default 15 seconds).
 
  --exists-action <action>    Default action when a path already exists: (s)witch, (i)gnore, (w)ipe,
 
                              (b)ackup, (a)bort).
 
  --trusted-host <hostname>  Mark this host as trusted, even though it does not have valid or
 
                              any HTTPS.
 
  --cert <path>              Path to alternate CA bundle.
 
  --client-cert <path>        Path to SSL client certificate, a single file containing the
 
                              private key and the certificate in PEM format.
 
  --cache-dir <dir>          Store the cache data in <dir>.
 
  --no-cache-dir              Disable the cache.
 
  --disable-pip-version-check
 
                              Don't periodically check PyPI to determine whether a new version
 
                              of pip is available for download. Implied with --no-index.
 
  --no-color                  Suppress colored output
 
 
</pre>
 
</pre>
  
== Lukt niet met sudo? (okt. 2018) ==
+
== Locatie van packages ==
  
Ik krijg het niet aan de praat icm. sudo:
+
Je kunt de locatie via de command line achterhalen. Bv.:
  
 
<pre>
 
<pre>
pip install --upgrade cryptography        # Lukt niet: sudo-rechten nodig
+
> pip3 show PyMysql
sudo pip install --upgrade cryptography  # Lukt niet: Kan pip niet vinden
+
 
 +
Name: PyMySQL
 +
Version: 0.10.1
 +
Summary: Pure Python MySQL Driver
 +
Home-page: https://github.com/PyMySQL/PyMySQL/
 +
Author: yutaka.matsubara
 +
Author-email: yutaka.matsubara@gmail.com
 +
License: "MIT"
 +
Location: /home/jeroen/.local/lib/python3.8/site-packages
 +
Requires:
 +
Required-by:  
 
</pre>
 
</pre>
 +
 +
Ongetwijfeld kun je packages ook op account-onafhankelijke locaties installeren (bv. op een webserver), maar die kennis heb ik nu niet paraat.
 +
 +
== Environments ==
 +
 +
[http://jakevdp.github.io/blog/2016/08/25/conda-myths-and-misconceptions/]:
 +
 +
:virtualenv/venv are utilites that allow users to create isolated Python environments that work with pip.
 +
 +
== Bronnen ==
 +
 +
* http://jakevdp.github.io/blog/2016/08/25/conda-myths-and-misconceptions/

Huidige versie van 16 dec 2020 om 15:02

Pip is de officiële Python package manager.

Dit artikel stamt uit 2018. Oude zooi (inclusief alles rondom Python2) heb ik in dec. 2020 verwijderd. Zie Geschiedenis weergeven als je dat toch nodig hebt. Dit artikel heeft uitsluitend betrekking op Python3.

Installatie

Dec. 2020, Linux Mint - Moeiteloos:

sudo apt install python3-pip

Testen:

> pip

bash: pip: command not found

> pip3

Usage:   
  pip3 <command> [options]
  ...

Installatie van packages

Bv.:

pip3 install pymysql

Locatie van packages

Je kunt de locatie via de command line achterhalen. Bv.:

> pip3 show PyMysql

Name: PyMySQL
Version: 0.10.1
Summary: Pure Python MySQL Driver
Home-page: https://github.com/PyMySQL/PyMySQL/
Author: yutaka.matsubara
Author-email: yutaka.matsubara@gmail.com
License: "MIT"
Location: /home/jeroen/.local/lib/python3.8/site-packages
Requires: 
Required-by: 

Ongetwijfeld kun je packages ook op account-onafhankelijke locaties installeren (bv. op een webserver), maar die kennis heb ik nu niet paraat.

Environments

[1]:

virtualenv/venv are utilites that allow users to create isolated Python environments that work with pip.

Bronnen