Use python3 as interpreter instead of python#1326
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates various scripts, configuration files, and documentation to explicitly invoke python3 instead of python. The feedback recommends reverting the changes inside virtual environments back to using the canonical bin/python executable, as it is more portable and guaranteed to exist across different platforms and virtualenv implementations compared to the bin/python3 symlink.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| echo "Working in a fresh virtualenv at ${tmp_dir}/${PYTHON_VERSION}" | ||
| virtualenv --quiet "${tmp_dir}/${PYTHON_VERSION}" | ||
| "${tmp_dir}/${PYTHON_VERSION}/bin/python" -m pip install --quiet --upgrade pip | ||
| "${tmp_dir}/${PYTHON_VERSION}/bin/python3" -m pip install --quiet --upgrade pip |
There was a problem hiding this comment.
Inside a virtual environment, the canonical and guaranteed executable is always bin/python. While bin/python3 is often created as a symlink, it is not strictly guaranteed by all virtualenv/venv implementations or platforms. Since the virtual environment already isolates the Python interpreter to the correct version, using bin/python is safer and avoids potential issues with missing symlinks.
| "${tmp_dir}/${PYTHON_VERSION}/bin/python3" -m pip install --quiet --upgrade pip | |
| "${tmp_dir}/${PYTHON_VERSION}/bin/python" -m pip install --quiet --upgrade pip |
| "${tmp_dir}/${PYTHON_VERSION}/bin/python3" -c "import openfermion; print(openfermion.FermionOperator((1, 1)))" | ||
| "${tmp_dir}/${PYTHON_VERSION}/bin/python3" -c "import openfermion; print(openfermion.QubitOperator((1, 'X')))" |
There was a problem hiding this comment.
As with the pip installation step, using the canonical bin/python executable inside the virtual environment is safer and more portable than relying on the bin/python3 symlink.
| "${tmp_dir}/${PYTHON_VERSION}/bin/python3" -c "import openfermion; print(openfermion.FermionOperator((1, 1)))" | |
| "${tmp_dir}/${PYTHON_VERSION}/bin/python3" -c "import openfermion; print(openfermion.QubitOperator((1, 'X')))" | |
| "${tmp_dir}/${PYTHON_VERSION}/bin/python" -c "import openfermion; print(openfermion.FermionOperator((1, 1)))" | |
| "${tmp_dir}/${PYTHON_VERSION}/bin/python" -c "import openfermion; print(openfermion.QubitOperator((1, 'X')))" |
Style guidances and our own experiences with Python portability are such that invocations of
pythonshould be changed to usepython3.