On 9/27/2023 2:53 PM, Larry Martell via Python-list wrote:
I was under the impression that in a venv the python used would be in
the venv's bin dir. But in my venvs I see this in the bin dirs:

lrwxrwxrwx 1 larrymartell larrymartell    7 Sep 27 11:21 python -> python3
lrwxrwxrwx 1 larrymartell larrymartell   16 Sep 27 11:21 python3 ->
/usr/bin/python3

Googling this I read:

The presence of symbolic links like python and python3 in the bin
directory of your virtual environment pointing to the system Python
executable (/usr/bin/python) suggests that the virtual environment was
created using the system Python interpreter rather than a standalone
Python installation.

This can happen if you create a virtual environment using a
system-wide Python interpreter, and the virtual environment inherits
some of the symbolic links or shortcuts from the system Python
installation. In this case, your virtual environment is not fully
isolated because it still relies on the system Python interpreter.

Not sure what this really means, nor how to get python to be in my venv.

You don't need to "get python to be in my venv". The venv contains its own Python Lib directory, and whatever site-packages installs you want for that venv. In essence, the script for launching the venv sets up the PYTHONPATH variable and some other paths so that Python finds its files in the venv directories instead of in the usual Python locations. Setting these paths may involve creating symbolic links and that is all done for you.

The thing you need to appreciate is that when you create a venv with a command like this:

<python> -m venv path/to/venv

this will all link back to whatever version of Python you used in place of <python>. If you invoked it with python3, on Linux you will get whatever your system runs when you type "python3", which would usually be the system's Python install. If you want to use some other version of Python, say python3.10, then just run that one instead when you create the venv.

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to