Sample Header Ad - 728x90

Is it safe to invoke `apt` from within a conda environment?

0 votes
0 answers
93 views
I have a Python script which manages upgrading the system by invoking apt with different arguments via the subprocess module. It relies on the python_toolkit and docker libraries, so these need to be installed. Up until now I've installed these two modules in the user's Python environment, that is, the OS's Python interpreter with the libraries residing somewhere in ~/. Python 3.12 now strongly recommends to not use Python without a virtual environment if external libraries need to be used, which can be overridden by adding --break-system-packages. For this reason I've installed python_toolkit and docker inside a miniconda environment and now executed my script once. It seems to have worked, but I am unsure if this is safe to do, to invoke apt from within a Conda environment, mostly due to the possible alteration of LD_LIBRARY_PATH. Should I better create a normal virtual environment, or might using --break-system-packages be just as good? In my case, nothing else than those two libraries will ever be needed for an environment-less Python. Everything else runs in Conda environments.
Asked by Daniel F (937 rep)
Jan 31, 2025, 02:54 PM
Last activity: Feb 1, 2025, 02:30 AM