`azdev setup` fails to call `python` executable from conda environment on win32
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 55/100
Research direction
Start in azdev/utilities/command.py at the py_cmd function and inspect how the Python executable is selected on win32. Reproduce azdev setup from an activated conda environment, then verify that package installation invokes the environment's working Python executable instead of the invalid Scripts/python path.
Written by the indexing model from the issue text.
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 <repopath> --repo <repopath>
=======================
| Azure CLI Dev Setup |
=======================
Azure CLI:
<repopath>
Azure CLI extension repos:
<repopath>
Installing packages
=====================
Upgrading pip...
Command `C:\Users\<username>\AppData\Local\Continuum\anaconda3\envs\az-dev\Scripts\python -m pip install --upgrade pip` failed with exit code 1:
'C:\Users\<username>\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:
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)
- Dominant language
- Python
- Stars
- 91
- Forks
- 134
- Avg merge
- 2h 51m
- Merged PRs (30d)
- 1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Azure/azure-cli-dev-tools
-
Difficulty 1/5 Under an hour Newbie friendliness 65/100
Azure/azure-cli-dev-tools#310 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
Azure/azure-cli-dev-tools#529 ·
-
Azure/azure-cli-dev-tools#525 · 1 assignee ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Azure/azure-cli-dev-tools#520 ·
-
Azure/azure-cli-dev-tools#519 · 1 comment · 1 reaction · 1 assignee ·
All issues in Azure/azure-cli-dev-tools
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
stephrobert/dsoxlab#238 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
sublimehq/package_control#1780 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
nwg-piotr/nwg-displays#145 ·