diff --git a/wiki/linux/package_manager.md b/wiki/linux/package_manager.md index d96b054..45e9b02 100644 --- a/wiki/linux/package_manager.md +++ b/wiki/linux/package_manager.md @@ -24,5 +24,8 @@ They distribute standalone applications that can run independently of the system single executable file. - [Flatpak](/wiki/linux/flatpak.md) distributes sandboxed desktop applications across different Linux distributions. -- [uv](/wiki/programming_language/python/uv.md) manages Python installations, virtual environments, - project dependencies and Python-based command-line tools. +- [uv](/wiki/programming_language/python/uv.md) manages Python installations, + [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. diff --git a/wiki/programming_language/python.md b/wiki/programming_language/python.md index bc19d81..55df8b1 100644 --- a/wiki/programming_language/python.md +++ b/wiki/programming_language/python.md @@ -29,7 +29,8 @@ to your `~/.profile`. You can then set and install your preferred version of python globally with `pyenv install ` and `pyenv global `. -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). ### Manual Installation @@ -168,25 +169,12 @@ directory. ## Modules -There are various modules and package managers to install these for Python like -`pip`. -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. +Python modules can be installed using package managers such as +[pip](/wiki/programming_language/python/pip.md) or [uv](/wiki/programming_language/python/uv.md). -A generally more favourable approach is to install modules using -[virtual environments](#using-virtual-environments). -This, however, is only practical for projects although some virtual environment package managers -such as [uv](/wiki/programming_language/python/uv.md) can also handle global installation of Python -pacakges. - -This section addresses various different modules. +For most projects it is recommended to use a [virtual environment](#using-virtual-environments). +For global installation the [system package managers](/wiki/linux/package_manager.md) can be used. +Alternatively pip and uv can also handle global installation. ### scikit-learn diff --git a/wiki/programming_language/python/pip.md b/wiki/programming_language/python/pip.md new file mode 100644 index 0000000..6800ce8 --- /dev/null +++ b/wiki/programming_language/python/pip.md @@ -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 `` with its name. + +```sh +pip install +``` + +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 +``` + +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 `` with the package +name. + +```sh +pip uninstall +``` + +### 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 . +```