mirror of
https://github.com/tiyn/wiki.git
synced 2026-05-07 02:11:34 +02:00
Programming Languages/Python: Added uv
This commit is contained in:
@@ -7,6 +7,28 @@ language.
|
||||
|
||||
You can install python using various ways.
|
||||
|
||||
### Installation From Package Managers
|
||||
|
||||
Using various [package managers](/wiki/linux/package_manager.md) the current python version can be
|
||||
easily installed.
|
||||
Additionally an [pyenv](#pyenv-installation), [uv](#uv-installation) or [manual installation](#manual-installation) can be
|
||||
done to get a specific older versions for projects.
|
||||
|
||||
### uv Installation
|
||||
|
||||
[uv](https://docs.astral.sh/uv/) is a python package and project manager.
|
||||
It can manage python versions.
|
||||
|
||||
Versions can be installed and set for the current directory and subdirectories as shown in the
|
||||
following commands where `<python-version>` is the python version.
|
||||
|
||||
```sh
|
||||
uv python install <python-version>
|
||||
uv python pin <python-version>
|
||||
```
|
||||
|
||||
uv can also be used to manage [virtual environments](#uv-virtual-environments).
|
||||
|
||||
### pyenv Installation
|
||||
|
||||
With [pyenv](https://github.com/pyenv/pyenv) you can easily switch between different versions.
|
||||
@@ -117,6 +139,33 @@ to it and run `pipreqs` (install it if not already done).
|
||||
|
||||
### Using Virtual Environments
|
||||
|
||||
There are various options to use virtual environments.
|
||||
The first and most commonly used option is [venv](#venv-virtual-environments).
|
||||
A more modern and arguably better approach is using [uv](#uv-virtual-environments).
|
||||
|
||||
#### uv Virtual Environments
|
||||
|
||||
Since uv is a project-based tool the following command has to be used to create a project where
|
||||
`<path>` is the path to the project directory.
|
||||
If it is omitted the project will be created in the current working directory.
|
||||
|
||||
```sh
|
||||
uv init <path>
|
||||
```
|
||||
|
||||
Additionally this command can be expanded with flags.
|
||||
To create the most basic form of a project without a `README.md` the `--bare` flag can be used.
|
||||
|
||||
To use uv as a virtual environment similar to venv the following command can be invoked inside a
|
||||
project directory.
|
||||
It will create a `.venv` directory containing the `bin/activate` file.
|
||||
|
||||
```sh
|
||||
uv venv
|
||||
```
|
||||
|
||||
#### venv Virtual Environments
|
||||
|
||||
[venv](https://docs.python.org/3/library/venv.html) can be used to create a virtual environment.
|
||||
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user