Azure / Azure/azure-cli-dev-tools

`azdev setup` fails to call `python` executable from conda environment on win32

Offen
#307 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Python
Sterne
91
Forks
134
Ø Merge
2 Std. 51 Min.
Gemergte PRs (30 T.)
1

Beschreibung

When running `azdev setup` from within a conda environment on win32, the `py_cmd` function in `azdev/utilities/command.py` attempts to run `Scripts/python` from within the current conda env, rather than the `python` executable in the root of the environment:

```
(base) PS> conda activate az-dev
(az-dev) PS> azdev setup --cli --repo

=======================
| Azure CLI Dev Setup |
=======================

Azure CLI:

Azure CLI extension repos:

Installing packages
=====================

Upgrading pip...
Command `C:\Users\\AppData\Local\Continuum\anaconda3\envs\az-dev\Scripts\python -m pip install --upgrade pip` failed with exit code 1:
'C:\Users\\AppData\Local\Continuum\anaconda3\envs\az-dev\Scripts\python' is not recognized as an internal or external command,
operable program or batch file.
```

As a workaround, modifying `py_cmd` to call `sys.executable` rather than using `env_path` seems to work:

```python
def py_cmd(command, message=False, show_stderr=True, raise_error=False, is_module=True, **kwargs):
""" Run a script or command with Python.
:param command: The arguments to run python with.
:param message: A custom message to display, or True (bool) to use a default.
:param show_stderr: On error, display the contents of STDERR.
:param raise_error: On error, raise CommandError.
:param is_module: Run a Python module as a script with -m.
:param kwargs: Any kwargs supported by subprocess.Popen
:returns: CommandResultItem object.
"""
from azdev.utilities import get_env_path
env_path = get_env_path()
python_bin = sys.executable
if is_module:
command = '{} -m {}'.format(python_bin, command)
else:
command = '{} {}'.format(python_bin, command)
return cmd(command, message, show_stderr, raise_error, **kwargs)
```

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Beginne in azdev/utilities/command.py bei der Funktion py_cmd und prüfe, wie die Python-Executable unter win32 ausgewählt wird. Reproduziere azdev setup aus einer aktivierten conda-Umgebung und verifiziere anschließend, dass die Paketinstallation die funktionierende Python-Executable der Umgebung anstelle des ungültigen Scripts/python-Pfads aufruft.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
cli, tooling
Issue-Typ
Bug
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
55/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.