Python Environment on KNEO Pi¶
KNEO Pi provides a robust Python development environment with Python3 pre-installed. Please follow the guidelines below to manage Python packages effectively and avoid potential conflicts.
Using Virtual Environments with pip¶
It is recommended to use a virtual environment when installing Python packages with pip. This isolates project dependencies from the system Python environment and prevents version conflicts or permission issues.
Create a virtual environment:
Activate the virtual environment: Install packages within the virtual environment: Deactivate the virtual environment when done:See error: externally-managed-environment ?
This error occurs when you attempt to use pip outside of a virtual environment in a Python installation managed by your operating system (e.g., installed via pacman). Pacman and Python’s pip both manage packages in the same global directories. Mixing them can cause file conflicts, version mismatches, or break system dependencies.
For detailed specifications, refer to PEP 668
Installing System-wide Packages with Pacman¶
If you intentionally need to install Python packages system-wide, you can use pacman directly. This approach integrates packages into the system environment and is suitable for administrative or shared setups.
Search for a package from Arch User Repository (AUR)
Install the package:Resolving Conflicts
If you have 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.