Skip to content

python3.exe missing on windows when creating a virtualvenv #2774

Open
@mortenb-buypass

Description

@mortenb-buypass

Issue

I mainly develop for linux on a windows so all my scripts start with #!/usr/bin/env python3

I created a precommit hack for git and it fails on the shebang python3 not found This is the first ever I've seen
the shebang being used on windows. So I discovered it was not there :-)

We have lots of legacy system with legacy python pointing to old version2 python, and -m venv creates a python3 softlink on linux

So it would be nice if they where the same.

I see I do not have a python3.exe under windows main python either, but how can we assure same file will run same binary

Environment

Provide at least:

  • OS: windows11
  • pip list of the host python where virtualenv is installed:
pip list
Package Version
------- -------
pip     24.2

Output of the virtual environment creation

Make sure to run the creation with -vvv --with-traceback:

python -m venv C:\dist\venvs\ranchercli
(trk-fullstack-test) PS C:\dist\trk-fullstack-test> C:\dist\venvs\ranchercli\Scripts\Activate.ps1
(ranchercli) PS C:\dist\trk-fullstack-test> where.exe python3
INFO: Could not find files for the given pattern(s).
(ranchercli) PS C:\dist\trk-fullstack-test> where.exe python 
C:\dist\venvs\ranchercli\Scripts\python.exe
C:\dist\python312\python.exe
(ranchercli) PS C:\dist\trk-fullstack-test> python --version
Python 3.12.6
(ranchercli) PS C:\dist\trk-fullstack-test> ls -l C:\dist\venvs\ranchercli\Scripts\


    Directory: C:\dist\venvs\ranchercli\Scripts


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----        30.09.2024     16:31           2052 activate
-a----        30.09.2024     16:31           1005 activate.bat
-a----        30.09.2024     16:31          26199 Activate.ps1
-a----        30.09.2024     16:31            393 deactivate.bat
-a----        30.09.2024     16:31         108402 pip.exe
-a----        30.09.2024     16:31         108402 pip3.12.exe
-a----        30.09.2024     16:31         108402 pip3.exe
-a----        30.09.2024     16:30         270104 python.exe
-a----        30.09.2024     16:30         258840 pythonw.exe

workaround

# just go into the rancher
cd C:\dist\venvs\ranchercli\Scripts\

I just checked 3.12.6 venv on ubuntu 22.04 and it has python3:

(ranchercli) mobj@BPOIMOBJ1:/dist$ python3 --version
Python 3.12.6
(ranchercli) mobj@BPOIMOBJ1:/dist$ ls -l ~/.venv/ranchercli/bin/
total 36
-rw-r--r-- 1 mobj mobj 9033 Sep 30 16:52 Activate.ps1
-rw-r--r-- 1 mobj mobj 2054 Sep 30 16:52 activate
-rw-r--r-- 1 mobj mobj  933 Sep 30 16:52 activate.csh
-rw-r--r-- 1 mobj mobj 2212 Sep 30 16:52 activate.fish
-rwxr-xr-x 1 mobj mobj  247 Sep 30 16:52 pip
-rwxr-xr-x 1 mobj mobj  247 Sep 30 16:52 pip3
-rwxr-xr-x 1 mobj mobj  247 Sep 30 16:52 pip3.12
lrwxrwxrwx 1 mobj mobj   10 Sep 30 16:52 python -> python3.12
lrwxrwxrwx 1 mobj mobj   10 Sep 30 16:52 python3 -> python3.12
lrwxrwxrwx 1 mobj mobj   48 Sep 30 16:52 python3.12 -> /home/mobj/.pyenv/versions/3.12.6/bin/python3.12

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions