You created a venv and activated it, but then ran your code with sudo. Sudo does not see your venv so it can't use any of the stuff installed in the venv.
When you specify the full path of the Python interpreter, with sudo or not, Python knows it belongs to a venv and does what it needs to do in order to work with the stuff installed in the venv.
If you are going to use venv's you need to learn about them, and how they work (at least the bare minimum basics of Python venv's).
It is very easy, you just need to do a little reading and pay attention to what you're reading so it sinks in. Here's a good start to read on the subject:
https://realpython.com/python-virtual-e ... -a-primer/
When you specify the full path of the Python interpreter, with sudo or not, Python knows it belongs to a venv and does what it needs to do in order to work with the stuff installed in the venv.
If you are going to use venv's you need to learn about them, and how they work (at least the bare minimum basics of Python venv's).
It is very easy, you just need to do a little reading and pay attention to what you're reading so it sinks in. Here's a good start to read on the subject:
https://realpython.com/python-virtual-e ... -a-primer/
Statistics: Posted by memjr — Sat Feb 10, 2024 7:24 am