If the same pip install command leaves one project broken, compare the interpreter used for installation with the one running the code. Also check whether several projects share one environment. The aim is an environment another person can recreate with the same execution conditions.
This series is based on Ubuntu 24.04 LTS and the updated Rocky Linux 9.x. Common examples use Python 3.12. Rather than choosing a version just because it is the latest Python, check the version supported by the project’s core libraries.
Python development environment · 01 selection and venv · 02 uv · 03 conda · 04 web Development·05 Data·AI·06 OCR·Service Separation
On this page
The first thing to divide is not the tool, but the scope of management
| floor | example | Mainly managed |
|---|---|---|
| Operating system and drivers | glibc, GPU driver, service/file permissions | OS package/driver installation procedure |
| Python launcher | Python 3.12.x | Managed Python in OS package, uv, conda |
| project package | FastAPI, pandas, Pillow | pip, uv project, conda environment in venv |
| External executable file/model | Tesseract, Poppler, OCR language data, AI model | OS or conda package/separate model repository |
| Run settings and data | DB address, input file, output, log | Environment variables/configuration files/storage |
venv creates an isolated package space with already existing Python. uv bundles Python selection, dependency specification, locking, and synchronization flows on top of it, and conda can deploy several non-Python libraries along with Python on an environment basis. The three are not replacements that do the exact same thing.
Advantages and burdens of venv·uv·conda
| tools | Advantages/suitable use | Burden and precautions |
|---|---|---|
| venv + pip | Simple structure with standard features. Small scripts, services based on existing requirements, learning basic principles | Prepare the Python launcher separately. Locking and update policies must be set separately, and OS executable files are not quarantined. |
| uv | Easy to manage Python, packages, lock files, and development dependencies together. Web API, deployment, team development/CI | You need to learn the specification and the role of lock files. Does not lock OS library, GPU driver, or model files |
| conda | Manage Python versions and native packages for scientific computing on an environment basis. Research, analysis, work with multiple binary dependencies | Environmental capacity and channel management burden. YAML alone does not provide accurate version locking and requires managing the order of mixing with pip. |
The above comparison is a selection criterion and not a speed ranking or answer for all projects. If the necessary dependencies are met with just the Python package wheel, an AI project can also be configured with uv or venv. Conversely, if a web service requires a combination of native libraries such as GDAL, there is reason to consider conda.
If the project is like this, where should I start?
- Personal automation in just a few files: Start with venv + pip and note how it runs and its dependencies.
- Tasks where the team will repeatedly create the same environment, such as web API/deployment: First review uv + pyproject.toml + uv.lock.
- Analysis centered on a combination of scientific computing, geospatial information, and native packages: Reviews the conda-forge-based conda environment.
- GPU inference, training and OCR: check the framework, driver and OS executable requirements, then decide whether to separate the CPU API environment from the GPU worker environment.
1. Check the current Python and OS
cat /etc/os-release
uname -m
command -v python3
python3 --version
df -h /
Just because Rocky Linux 9’s default python3 is 3.9 doesn’t mean you need to overwrite your system path with 3.12. In your project, you just need to specify python3.12. This series does not use the /usr/bin/python3 change or the system-wide sudo pip install.
2. Prepare Python 3.12 for each OS
Python 3.12 and venv on Ubuntu 24.04
sudo apt update
sudo apt install -y python3.12 python3.12-venv python3-pip git curl ca-certificates
python3.12 --version
In Ubuntu, the modules required for venv are prepared as separate packages. If you receive an error related to No module named venv or ensurepip, first check that the Python version you ran and the venv package are correct. Written based on the python3.12-venv package of Ubuntu 24.04.
Preparing Python 3.12 and pip on Rocky Linux 9
sudo dnf install -y python3.12 python3.12-pip git curl ca-certificates
python3.12 --version
Rocky Linux 9 uses a healthy AppStream repository with Python 3.12 packages available. If you have an older version of 9.x installed or the storage is fixed, check the OS update policy first. The RHEL series parallel Python package configuration can also be found in the RHEL 9 Python installation document.
3. Create a .venv for each project
mkdir -p ~/projects/venv-demo
cd ~/projects/venv-demo
python3.12 -m venv .venv
source .venv/bin/activate
python --version
python -m pip --version
python -c 'import sys; print(sys.executable); print(sys.prefix != sys.base_prefix)'
Make sure the executor path is .venv/bin/python in the current project and the last value is True. Activation is a convenience function that first searches the PATH for executable files in this environment. You can also call .venv/bin/python directly without enabling it. Python venv document explains this behavior.
4. Install the package and record the installation status
printf '%s\n' 'requests>=2.32,<3' > requirements.in
python -m pip install -r requirements.in
python -m pip check
python -m pip freeze > requirements-linux-py312.txt
python -c 'import requests; print(requests.__version__)'
deactivate
requirements.in is a file that contains the intent of the dependencies you selected, and the freeze file created here is , a list of versions installed in the current environment, and . pip freeze alone does not guarantee reproducibility for all OS, architecture, and Python versions. If hash verification or platform-specific locking is required, separate locking tools and policies must be applied.
# 같은 OS·아키텍처·Python 계열의 별도 확인용 환경
python3.12 -m venv .venv-rebuild
.venv-rebuild/bin/python -m pip install -r requirements-linux-py312.txt
.venv-rebuild/bin/python -m pip check
.venv-rebuild/bin/python -c 'import requests; print(requests.__version__)'
Re-create the .venv folder as a specification instead of copying it to another server. This is because absolute paths can be included in scripts in the environment, and binary dependencies also depend on host conditions. Place project code and data outside .venv.
Why does the OS prevent pip from installing?
externally-managed-environment can come up in situations where you try to change with pip to a Python installation area managed by the OS. First, make sure you are running inside venv. This series does not use the method of adding --break-system-packages to eliminate errors. Externally managed Python environment specification addresses conflicts between OS packages and the Python package manager.
Failure to isolate the development environment
venv is not a security sandbox. The executed code retains the user’s file and network permissions. DB server, Redis, GPU driver, and system library are also separate layers. As the project grows, these external conditions need to be recorded in the README or deployment settings as well as the environment file.
We now continue the same work with 02 uv, which focuses on specification and lock file management.
Download series example file·venv·conda specification, uv·web·data·OCR example source, and confirmed uv lock file are bundled. It is executed from each project directory, and the OS package is prepared separately through the procedures in the main text.



