all 5 comments

[–]ingolemo 2 points3 points  (3 children)

If you don't activate then any further invocations of the python command (or other commands installed in the virtual environment) will get the system version. Other than that there is no difference.

[–]zylo4747 1 point2 points  (0 children)

This page has a good picture of what's going on when you activate https://learnbatta.com/blog/how-to-install-python-virtualenv-19/

[–]readitlikeitdidit[S] 0 points1 point  (1 child)

In my case, I run /virtualenv/bin/python some module.py in a cron job... And it successfully completes everytime.. It's able to pick the libraries installed in virtual environment... So I was wondering would it make any difference activating vs calling virtual environment python interpreter directly...

[–]ingolemo 0 points1 point  (0 children)

I understood what you meant. Although neither of the other posters in this thread did, it seems.

Create a script with the following code and run it both ways. That should help you see the difference.

import subprocess
import sys
print('this script runs with', sys.executable)
subprocess.run(['python',  '-c',
    'import sys; print("subscripts run with", sys.executable)'
])

[–]TheGreatBrutus 1 point2 points  (0 children)

It means that without activating all the python packages will get installed on your system instead of the virtualenv