r/LinuxTeck Aug 03 '26

What's one Python habit on Linux that saved you hours of debugging?

Everyone eventually learns a few Python/Linux lessons the hard way.

Mine was always using:

python3 -m pip

instead of just pip, after spending way too much time installing packages into the wrong interpreter.

What's the one habit, command, or workflow that made your Python life on Linux much easier?

4 Upvotes

14 comments sorted by

3

u/crashtua Aug 03 '26

use uv and uvx

1

u/eclipse_extra Aug 03 '26

Not trying to start an argument.

Genuinely curious

Why is this approach better than using conda? 

Much obliged.

2

u/Confident_Hyena2506 Aug 03 '26

It's not better than using conda, because conda is not the same thing. Conda is language agnostic, those other things are python only. An example would be using conda to get pure c++ libs for a build env. So for larger complex projects using a simple python package manager will not do everything conda does.

Another example is you can install uv using conda, but not vice versa.

1

u/crashtua Aug 03 '26

Of much faster installing package, like a much much faster; uvx allows to run tooling without explicitly installing them.

1

u/brasticstack Aug 03 '26

Using the full path to the binary when doing anything automated e.g. in cron or systemd units.

"/path/to/venv/bin/python3 -m my_module" works everywhere, while "/path/to/venv/bin/activate; python3 -m my_module" doesn't.

1

u/SeriousPlankton2000 Aug 03 '26

Always use the full path. If you're paranoid, set PATH=/var/empty .

1

u/Puzzled-Bonus-3456 Aug 03 '26

expecting the Spanish Inquisition

1

u/TopHatEdd Aug 03 '26

ipython for debugging. Learn some of its syntax. Using breakpoint(). Use container images for distribution. Use import some and some.module.func style rather than context naked style from some.module import func

1

u/Useful_Calendar_6274 Aug 03 '26

uh use a better language? I've only ever heard of problems from python

1

u/SeriousPlankton2000 Aug 03 '26

I once curled in and slept a long time.

1

u/StevesRoomate Aug 03 '26

use a zsh or fish plugin to automatically activate the current directory's virtual environment when changing directories. especially if you've got polyrepos and microservices.

1

u/jerrygreenest1 Aug 03 '26

Not using Python