Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Open
#307 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
55/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
python
Domain
cli, tooling

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Azure/azure-cli-dev-tools

All issues in Azure/azure-cli-dev-tools

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.