0

I have a powershell script which is meant to create a virtual environment with the following command:

py -3.6 -m venv --clear env

I have verified that I can do this when I run the above command in a powershell window, and the environment is created. However when I run the powershell script via an azure release pipeline, I get the following error:

python : The term 'python' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

I have verified that my user PATH environment variable has all the necessary paths:

C:\Python36\Scripts\;C:\Python36\;%USERPROFILE%\AppData\Local\Microsoft\WindowsApps;C:\Python36\Lib\site-packages\pywin32_system32;C:\Python36\Lib\site-packages\win32;C:\Automation\app\env\Scripts;C:\Python38;C:\Python38\Scripts;C:\Python38\Lib\site-packages\win32;C:\Python38\Lib\site-packages\pywin32_system32

Specs:

Python: 3.6.7 OS: Windows 10 Environment: Azure virtual machine.

Any help would be much appreciated.

1
  • 2
    Sounds like Python isn't available/configured properly in the pipeline environment Commented Feb 1, 2022 at 9:37

2 Answers 2

2

There seems to be a change when the variable is injected into the pipeline.

Try using:

PYTHON -3_6 -M VENV --clear ENV

Environment variables: Environment variables are specific to the operating system you are using. They are injected into a pipeline in platform-specific ways. The format corresponds to how environment variables get formatted for your specific scripting platform.

On UNIX systems (macOS and Linux), environment variables have the format $NAME. On Windows, the format is %NAME% for batch and $env:NAME in PowerShell.

System and user-defined variables also get injected as environment variables for your platform. When variables are turned into environment variables, variable names become uppercase, and periods turn into underscores. For example, the variable name any.variable becomes the variable name $ANY_VARIABLE.

https://learn.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=yaml%2Cbatch#environment-variables

Sign up to request clarification or add additional context in comments.

2 Comments

It runs out I hadn't added the paths to the system variables (in windows there are user environment variables and system environment variables, and pywin32 uses the system ones. )
The agent runs as a service I suspect, in that case it won't pick up your user environment variables. If you were to go into the registry to edit the environment for the user the service runs under, it will pick up those.
0

It runs out I hadn't added the paths to the system variables (in windows there are user environment variables and system environment variables, and pywin32 uses the system ones.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.