Azure / Azure/azure-cli-dev-tools
`azdev setup` fails to call `python` executable from conda environment on win32
- Langage dominant
- Python
- Étoiles
- 91
- Forks
- 134
- Merge moyen
- 2 h 51 min
- PR mergées (30 j)
- 1
Description
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)
```
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Piste de recherche
Commencez dans azdev/utilities/command.py, au niveau de la fonction py_cmd, et examinez comment l’exécutable Python est sélectionné sous win32. Reproduisez azdev setup depuis un environnement conda activé, puis vérifiez que l’installation du paquet invoque l’exécutable Python fonctionnel de l’environnement au lieu de l’emplacement Scripts/python invalide.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- cli, tooling
- Type d'issue
- Bug
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Activité
- À l'abandon
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 55/100