• path to python in venv

    From Larry Martell@21:1/5 to All on Wed Sep 27 11:53:57 2023
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jon Ribbens@21:1/5 to Larry Martell on Wed Sep 27 18:56:39 2023
    On 2023-09-27, Larry Martell <larry.martell@gmail.com> 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
    ...
    Not sure what this really means, nor how to get python to be in my venv.

    WHy do you want python to be "in your venv"?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Larry Martell@21:1/5 to python-list@python.org on Wed Sep 27 12:46:06 2023
    On Wed, Sep 27, 2023 at 12:42 PM Jon Ribbens via Python-list <python-list@python.org> wrote:

    On 2023-09-27, Larry Martell <larry.martell@gmail.com> 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
    ...
    Not sure what this really means, nor how to get python to be in my venv.

    WHy do you want python to be "in your venv"?

    Isn't that the entire point of a venv? To have a completely self
    contained env? So if someone messes with the system python it will not
    break code running in the venv.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Niktar Lirik@21:1/5 to python-list@python.org on Wed Sep 27 22:52:59 2023
    Hi Larry,
    You could just create venv with option '—copies'

    For example:
    python -m venv -–copies .venv


    From: Larry Martell via Python-list
    Sent: 27 сентября 2023 г. 22:48
    To: Jon Ribbens
    Cc: python-list@python.org
    Subject: Re: path to python in venv

    On Wed, Sep 27, 2023 at 12:42 PM Jon Ribbens via Python-list <python-list@python.org> wrote:

    On 2023-09-27, Larry Martell <larry.martell@gmail.com> 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
    ...
    Not sure what this really means, nor how to get python to be in my venv.

    WHy do you want python to be "in your venv"?

    Isn't that the entire point of a venv? To have a completely self
    contained env? So if someone messes with the system python it will not
    break code running in the venv.
    --
    https://mail.python.org/mailman/listinfo/python-list

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Larry Martell@21:1/5 to niktarlirik@zohomail.com on Wed Sep 27 13:01:46 2023
    On Wed, Sep 27, 2023 at 12:53 PM Niktar Lirik <niktarlirik@zohomail.com> wrote:

    Hi Larry,

    You could just create venv with option '—copies'



    For example:

    python -m venv -–copies .venv

    Thanks! That is just what I was looking for.

    From: Larry Martell via Python-list
    Sent: 27 сентября 2023 г. 22:48
    To: Jon Ribbens
    Cc: python-list@python.org
    Subject: Re: path to python in venv



    On Wed, Sep 27, 2023 at 12:42 PM Jon Ribbens via Python-list

    <python-list@python.org> wrote:



    On 2023-09-27, Larry Martell <larry.martell@gmail.com> 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

    ...

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



    WHy do you want python to be "in your venv"?



    Isn't that the entire point of a venv? To have a completely self

    contained env? So if someone messes with the system python it will not

    break code running in the venv.

    --

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



    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mats Wichmann@21:1/5 to Larry Martell via Python-list on Wed Sep 27 14:09:41 2023
    On 9/27/23 13:46, Larry Martell via Python-list wrote:
    On Wed, Sep 27, 2023 at 12:42 PM Jon Ribbens via Python-list <python-list@python.org> wrote:

    On 2023-09-27, Larry Martell <larry.martell@gmail.com> 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
    ...
    Not sure what this really means, nor how to get python to be in my venv.

    WHy do you want python to be "in your venv"?

    Isn't that the entire point of a venv? To have a completely self
    contained env? So if someone messes with the system python it will not
    break code running in the venv.

    It can do that, it just turns out the defaults are to not make a
    dedicated Python instance, and to not give access to the system site
    packages. The venv and virtualenv modules, at least, will let you
    override either of those defaults via command-line options at creation time.

    Once a year I have virtualenvs break when the new Python version appears
    in Fedora, which is irritating, but I take the attitude that virtualenvs
    are disposable and (try to) not let it bother me that I forgot to deal
    with that ahead of time. It helps if you make sure that a virtualenv
    has a record of its dependencies - perhaps a requirements.txt file in
    the project it's being used to build, so it's easy to recreate them.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jon Ribbens@21:1/5 to Larry Martell on Wed Sep 27 20:32:25 2023
    On 2023-09-27, Larry Martell <larry.martell@gmail.com> wrote:
    On Wed, Sep 27, 2023 at 12:42 PM Jon Ribbens via Python-list
    <python-list@python.org> wrote:
    On 2023-09-27, Larry Martell <larry.martell@gmail.com> 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
    ...
    Not sure what this really means, nor how to get python to be in my venv. >>
    WHy do you want python to be "in your venv"?

    Isn't that the entire point of a venv? To have a completely self
    contained env? So if someone messes with the system python it will not
    break code running in the venv.

    The main point of the venv is to isolate the installed packages,
    rather than Python itself. I'm a bit surprised your symlinks are
    as shown above though - mine link from python to python3.11 to /usr/bin/python3.11, so it wouldn't change the version of python
    used even if I installed a different system python version.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Peter J. Holzer@21:1/5 to Jon Ribbens via Python-list on Thu Sep 28 00:51:45 2023
    On 2023-09-27 20:32:25 -0000, Jon Ribbens via Python-list wrote:
    On 2023-09-27, Larry Martell <larry.martell@gmail.com> wrote:
    On Wed, Sep 27, 2023 at 12:42 PM Jon Ribbens via Python-list<python-list@python.org> wrote:
    On 2023-09-27, Larry Martell <larry.martell@gmail.com> wrote:
    lrwxrwxrwx 1 larrymartell larrymartell 7 Sep 27 11:21 python -> python3
    lrwxrwxrwx 1 larrymartell larrymartell 16 Sep 27 11:21 python3 -> /usr/bin/python3
    [...]
    I'm a bit surprised your symlinks are as shown above though - mine
    link from python to python3.11 to /usr/bin/python3.11, so it wouldn't
    change the version of python used even if I installed a different
    system python version.

    That's probably because you created the venvs with "python3.11 -m venv ...". The symlink points to the command you used to create it:

    % python3 -m venv venv
    % ll venv/bin/python*
    lrwxrwxrwx 1 hjp hjp 7 Aug 29 2022 venv/bin/python -> python3*
    lrwxrwxrwx 1 hjp hjp 12 Aug 29 2022 venv/bin/python3 -> /bin/python3* lrwxrwxrwx 1 hjp hjp 7 Aug 29 2022 venv/bin/python3.10 -> python3*

    % python3.10 -m venv venv
    % ll venv/bin/python*
    lrwxrwxrwx 1 hjp hjp 10 Sep 28 00:45 venv/bin/python -> python3.10*
    lrwxrwxrwx 1 hjp hjp 10 Sep 28 00:45 venv/bin/python3 -> python3.10*
    lrwxrwxrwx 1 hjp hjp 15 Sep 28 00:45 venv/bin/python3.10 -> /bin/python3.10*

    hp

    --
    _ | Peter J. Holzer | Story must make more sense than reality.
    |_|_) | |
    | | | hjp@hjp.at | -- Charles Stross, "Creative writing
    __/ | http://www.hjp.at/ | challenge!"

    -----BEGIN PGP SIGNATURE-----

    iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAmUUsfwACgkQ8g5IURL+ KF13XQ/6AzOJy/z+k0+l8lOtIEfBjEiAoW3iE8GqwZzO+ecZAkZiyNUD7JkHtxC/ Lq6RnqpbYcnszFN7gAAB7WHwuOLLohVCNKdwwIWgyjtRQc5BtIbcz+M+v8AbU/Qj iZ7ofJwkDyJdM86QvO3jD9ecD2dHRgTXIImRb9sf0WdrVoUF2Hwa5ZtVuMVvNg9l xf3rZ9A1qpdd/rJXZDI7LvnO62GeHmqdwhdEhSYTxPdWfq/kLd33Gdn1I7Gtb1kf tXvvGMenU+vH6MDyhqqgqxSjTz3ZglBDZnqgQ34Y+yoJOPibtYq8nZBM0RORJCdd Ppcaos8DJ3C4F7WnoqvrRc5K94Sq/WyzVadazeAcyigAz07M/BfsZrtLpRCO+CqC l6pPxe0C3iKWVsnSZ+BSD8/i7inpN7Nta3n4p7fcdhiFSHYkvrosk1bno+YOLcsl Btg7t0A/RyoIK4eVi3BbodrFuWqetkwjpLZLv+5RaOx+LjUJ51/f2jI1NUAhx07H zyD0BmdV/NKyaD8h53/8XI56gLvlM7G9GRNuww5jwx+3pTgD49If90ISzFoHVdSa 1woK7beNPaOkvzX40Kq1X+aK3oj5g8hGub1o4V8b0hpdEG8S3baMq9sGq/ZyFhXx K218OiNdaXlhYvi/Vo40nKrO2jZWmuWFYkEDzqq
  • From dn@21:1/5 to Jon Ribbens via Python-list on Thu Sep 28 11:42:36 2023
    On 28/09/2023 09.32, Jon Ribbens via Python-list wrote:
    On 2023-09-27, Larry Martell <larry.martell@gmail.com> wrote:
    On Wed, Sep 27, 2023 at 12:42 PM Jon Ribbens via Python-list
    <python-list@python.org> wrote:
    On 2023-09-27, Larry Martell <larry.martell@gmail.com> 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
    ...
    Not sure what this really means, nor how to get python to be in my venv. >>>
    WHy do you want python to be "in your venv"?

    Isn't that the entire point of a venv? To have a completely self
    contained env? So if someone messes with the system python it will not
    break code running in the venv.

    The main point of the venv is to isolate the installed packages,
    rather than Python itself. I'm a bit surprised your symlinks are
    as shown above though - mine link from python to python3.11 to /usr/bin/python3.11, so it wouldn't change the version of python
    used even if I installed a different system python version.


    "venv — Creation of virtual environments" (https://docs.python.org/3/library/venv.html) starts by saying:

    «The venv module supports creating lightweight “virtual environments”, each with their own independent set of Python packages installed in
    their site directories.»

    but later expands this with: «Used to contain a specific Python interpreter...» even though the primary use-case treats the system
    interpreter as the "base" Python/environment.

    Time for some reading and proving appropriate combinations of options?


    Over the years there have been various proposals to enable multiple
    versions of Python to exist concurrently on a single machine, notably
    Python2 + Python3 - but am failing to recall any official docs on
    Python3.n + Python3.m; eg "PEP 554 – Multiple Interpreters in the
    Stdlib" (https://peps.python.org/pep-0554/).

    That said there's plenty of articles on-line (which may/not feature
    venv*) such as "Multiple Python interpreters" (https://developer.fedoraproject.org/tech/languages/python/multiple-pythons.html)

    * although the OP didn't mention an OpSys, one poster did mention Fedora-Linux...


    NB some of this info may be dated - it is some time since conducted this investigation (and decided not to use venv - apologies!)

    Am currently using PyCharm (courtesy of recent teams' conventions) and
    it eases both problems (which interpreter, and which development-environment/activation steps) but in automating 'the boring
    stuff' it will be interesting to see if in-future, I notice when the
    project is based upon an older system!
    FYI https://www.jetbrains.com/help/pycharm/installing-uninstalling-and-reloading-interpreter-paths.html
    (I'd be surprised if the other major tool-sets don't offer something
    similar)

    Disclaimer: JetBrains sponsor our local PUG-meetings with a door-prize.

    --
    --
    Regards,
    =dn

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Thomas Passin@21:1/5 to Larry Martell via Python-list on Wed Sep 27 20:28:17 2023
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)