Skip to content

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)

pacman -Ss python-{package_name}
Install the package:

sudo pacman -S python-{package_name}
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:

pip uninstall {package_name}
Install the equivalent package using pacman:

sudo pacman -S python-{package_name}
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:

sudo pacman -S python-virtualenv
Create a virtual environment:
python3 -m venv myenv
Activate the virtual environment:
source myenv/bin/activate
Install packages within the virtual environment:
pip install {package_name}
Deactivate the virtual environment when done:
deactivate
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 to pacman for system-wide packages.
  • For project-specific packages, always use virtual environments created with python-virtualenv to manage dependencies safely.