Python Environment on KNEO Pi¶
KNEO Pi provides a robust Python development environment with Python 3.12
pre-installed. To manage Python packages effectively and avoid potential conflicts, follow these guidelines.
Important
when you are using pip
the same installation folder is shared with pacman
and most of time, especially when you are updating all system packages (pacman -Suy
), will raise a conflict error, such as version mismathes and borken dependencies. You always have to prefer the first option above. To solve conflict problems, just uninstall pip package and install they equivalent package on pacman.
Installing Python Packages with Pacman¶
To search and install Python packages using pacman, run:
Search for a package from Arch User Repository (AUR)
Install the package: This ensures that system-wide packages are managed correctly and conflicts are minimized.Resolving Conflicts¶
If you’ve installed packages using pip
and encounter conflicts, follow these steps to resolve them:
Uninstall the conflicting pip package:
Install the equivalent package using pacman: This approach ensures that the system maintains stability by using the pacman package manager for system-wide installations.Using Virtual Environments with pip
¶
To safely use pip
for installing additional Python packages without affecting the system, it’s recommended to use a virtual environment. See Python official documenation for details.
Install the virtual environment tool:
Create a virtual environment: Activate the virtual environment: Install packages within the virtual environment: Deactivate the virtual environment when done: By using virtual environments, you can safely manage project-specific dependencies without interfering with the system’s Python environment.Note
- Use
pacman
for system-wide Python package management to avoid conflicts. - Resolve conflicts by switching from
pip
topacman
for system-wide packages. - For project-specific packages, always use virtual environments created with
python-virtualenv
to manage dependencies safely.