mirror of
https://github.com/tiyn/wiki.git
synced 2026-07-26 12:21:35 +02:00
Python: Created Own pip Entry
This commit is contained in:
@@ -24,5 +24,8 @@ They distribute standalone applications that can run independently of the system
|
|||||||
single executable file.
|
single executable file.
|
||||||
- [Flatpak](/wiki/linux/flatpak.md) distributes sandboxed desktop applications across different
|
- [Flatpak](/wiki/linux/flatpak.md) distributes sandboxed desktop applications across different
|
||||||
Linux distributions.
|
Linux distributions.
|
||||||
- [uv](/wiki/programming_language/python/uv.md) manages Python installations, virtual environments,
|
- [uv](/wiki/programming_language/python/uv.md) manages Python installations,
|
||||||
project dependencies and Python-based command-line tools.
|
[virtual environments](/wiki/programming_language/python.md#using-virtual-environments), project
|
||||||
|
dependencies and Python-based command-line tools.
|
||||||
|
- [pip](/wiki/programming_language/python/pip.md) manages Python installations and can be used in a
|
||||||
|
virtual environment.
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ to your `~/.profile`.
|
|||||||
You can then set and install your preferred version of python globally with
|
You can then set and install your preferred version of python globally with
|
||||||
`pyenv install <version>` and `pyenv global <version>`.
|
`pyenv install <version>` and `pyenv global <version>`.
|
||||||
|
|
||||||
Analog to managing python versions, `pipenv` can manage pip and package versions.
|
Analog to managing python versions, `pipenv` can manage
|
||||||
|
[pip](/wiki/programming_language/python/uv.md) and package versions.
|
||||||
A guide and description of the usage can be found on [gioele.io](https://gioele.io/pyenv-pipenv).
|
A guide and description of the usage can be found on [gioele.io](https://gioele.io/pyenv-pipenv).
|
||||||
|
|
||||||
### Manual Installation
|
### Manual Installation
|
||||||
@@ -168,25 +169,12 @@ directory.
|
|||||||
|
|
||||||
## Modules
|
## Modules
|
||||||
|
|
||||||
There are various modules and package managers to install these for Python like
|
Python modules can be installed using package managers such as
|
||||||
`pip`.
|
[pip](/wiki/programming_language/python/pip.md) or [uv](/wiki/programming_language/python/uv.md).
|
||||||
For this usually a virtual environment is needed – as it is described in
|
|
||||||
[the setup section](#setup).
|
|
||||||
Alternatively local package manager like the
|
|
||||||
[ones of various Linux distributions](/wiki/linux/package_manager.md) can sometimes be used to
|
|
||||||
install packages globally.
|
|
||||||
Due to different package versions (especially on rolling release distributions) this can fail.
|
|
||||||
If it doesn't work the packages can be installed globally using `pip` together with the
|
|
||||||
`--break-system-packages` flag.
|
|
||||||
This flag is to be used with care.
|
|
||||||
|
|
||||||
A generally more favourable approach is to install modules using
|
For most projects it is recommended to use a [virtual environment](#using-virtual-environments).
|
||||||
[virtual environments](#using-virtual-environments).
|
For global installation the [system package managers](/wiki/linux/package_manager.md) can be used.
|
||||||
This, however, is only practical for projects although some virtual environment package managers
|
Alternatively pip and uv can also handle global installation.
|
||||||
such as [uv](/wiki/programming_language/python/uv.md) can also handle global installation of Python
|
|
||||||
pacakges.
|
|
||||||
|
|
||||||
This section addresses various different modules.
|
|
||||||
|
|
||||||
### scikit-learn
|
### scikit-learn
|
||||||
|
|
||||||
|
|||||||
49
wiki/programming_language/python/pip.md
Normal file
49
wiki/programming_language/python/pip.md
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
# pip
|
||||||
|
|
||||||
|
[pip](https://pip.pypa.io/) is the default package manager for Python.
|
||||||
|
It is used to install, update and remove Python packages from the Python Package Index (PyPI) and
|
||||||
|
other package repositories.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
### Installing Packages
|
||||||
|
|
||||||
|
A package can be installed by replacing `<package>` with its name.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pip install <package>
|
||||||
|
```
|
||||||
|
|
||||||
|
It is generally recommended to install packages inside a
|
||||||
|
[virtual environment](/wiki/programming_language/python.md#using-virtual-environments).
|
||||||
|
Alternatively, project-based package managers such as [uv](/wiki/programming_language/python/uv.md)
|
||||||
|
can be used.
|
||||||
|
|
||||||
|
On some Linux distributions global installation may require the
|
||||||
|
`--break-system-packages` flag.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pip install --break-system-packages <package>
|
||||||
|
```
|
||||||
|
|
||||||
|
This option should only be used if the package cannot be installed using the
|
||||||
|
[system package manager](/wiki/linux/package_manager.md#list-of-package-managers) or inside a
|
||||||
|
virtual environment.
|
||||||
|
|
||||||
|
### Removing Packages
|
||||||
|
|
||||||
|
Installed packages can be removed by replacing `<package>` with the package
|
||||||
|
name.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pip uninstall <package>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Creating a `requirements.txt` File
|
||||||
|
|
||||||
|
To automatically create a `requirements.txt` file for the current project,
|
||||||
|
navigate to the project directory and run `pipreqs`.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pipreqs .
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user