Python error: externally-managed-environment - easiest way to launch the .py with custom modules?

Hi, it appears to me that the Debian 12 suggests to install python modules in separation between various python apps to prevent conflicts:
cd /PyApp/ && python3 -m venv .venv && source .venv/bin/activate && python3 -m pip install -r requirements.txt && /PyApp/.venv/bin/python3 /PyApp/app.py

That is pretty complicated way to install required modules and launch the app. In my case the .venv folder is 110MB big - not insignificant for one app.

Do I understand correctly that this is now “new” universal way to install python app modules and launch py app? Or is there easier approach which allows launching app witch “python3” prefix instead of .venv one while still preventing conflicts of a different python module versions across various apps?

One can install latest module using Debian package manager:

apt search python-|grep gevent # if I want gevent module
sudo apt install python3-gevent

Issue I had is that the requirements.txt contained around 15 lines including those like “PySocks>=1.6.8”.

Mine mentioned complicated method using venv works, it only is too complicated for me to remember and it requires remembering to launch the .py using python “inside venv” which is again complicated. So here goes again my question above highlighted in a bold text.

That is actually recommend way or use Docker image. Python or PHP with 3rd party package manager is a mess.

1 Like