Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 无法在自托管Azure VM上运行Python Selenium测试_Python 3.x_Selenium Webdriver_Azure Devops_Azure Pipelines_Azure Virtual Machine - Fatal编程技术网

Python 3.x 无法在自托管Azure VM上运行Python Selenium测试

Python 3.x 无法在自托管Azure VM上运行Python Selenium测试,python-3.x,selenium-webdriver,azure-devops,azure-pipelines,azure-virtual-machine,Python 3.x,Selenium Webdriver,Azure Devops,Azure Pipelines,Azure Virtual Machine,我正试图从Azure管道在我的自托管VM中执行Selenium测试。我收到下面的错误消息 ##[错误]体系结构x64的版本规范3.8与Agent.ToolsDirectory中的任何版本都不匹配。 下面是我的Yaml trigger: - main pool: default strategy: matrix: Python38: python.version: '3.8' addToPath: true steps: - task: UsePython

我正试图从Azure管道在我的自托管VM中执行Selenium测试。我收到下面的错误消息

##[错误]体系结构x64的版本规范3.8与Agent.ToolsDirectory中的任何版本都不匹配。

下面是我的Yaml

trigger:
- main

pool: default strategy:   matrix:
    Python38:
      python.version: '3.8'
      addToPath: true

steps:
- task: UsePythonVersion@0   inputs:
    versionSpec: '$(python.version)'
    addToPath: true
    architecture: 'x64'   displayName: 'Use Python $(python.version)'

- script: |
    python -m pip install --upgrade pip
    pip install -r requirements.txt   displayName: 'Install dependencies'

- script: |
    pip install pytest-azurepipelines
    pytest tests\test_smoke\test_suite_SmokeTest.py -s -v --browser Chrome --html=report.html --reruns 2   displayName: 'pytest'

- task: DownloadPipelineArtifact@2   inputs:
    buildType: 'specific'
    project: '8801f21d-f4e9-4b65-b01e-68baf825747c'
    definition: '5'
    buildVersionToDownload: 'latest'
    targetPath: '$(Pipeline.Workspace)'

我已经在我的虚拟机中配置了代理。我还在VM中安装了python 3.8.6,并为其配置了python路径。

无法在自托管Azure VM上运行Python Selenium测试

要在私有代理上使用此任务,我们需要将所需的Python版本添加到自托管代理上的工具缓存中,以便任务使用它

通常,工具缓存位于代理的_work/_tool目录下,或者您可以使用命令行任务回显变量
$(agent.ToolsDirectory)
,以获取路径

然后,在该目录下,根据Python版本创建以下目录结构:

$AGENT_TOOLSDIRECTORY/
    Python/
        {version number}/
            {platform}/
                {tool files}
            {platform}.complete
版本号应遵循1.2.3的格式。站台 应为x86或x64。工具文件应该是解压后的文件 Python版本文件。{platform}.complete应该是一个0字节的文件 这看起来像x86.complete或x64.complete,只是表示 工具已正确安装在缓存中

我的测试目录结构:

$AGENT_TOOLSDIRECTORY/
    Python/
        3.9.0/
            x64/
                python-3.9.0-amd64.exe
            x64.complete

现在,它在我的自托管代理上运行良好:

你可以参考更多的细节

无法在自托管Azure VM上运行Python Selenium测试

要在私有代理上使用此任务,我们需要将所需的Python版本添加到自托管代理上的工具缓存中,以便任务使用它

通常,工具缓存位于代理的_work/_tool目录下,或者您可以使用命令行任务回显变量
$(agent.ToolsDirectory)
,以获取路径

然后,在该目录下,根据Python版本创建以下目录结构:

$AGENT_TOOLSDIRECTORY/
    Python/
        {version number}/
            {platform}/
                {tool files}
            {platform}.complete
版本号应遵循1.2.3的格式。站台 应为x86或x64。工具文件应该是解压后的文件 Python版本文件。{platform}.complete应该是一个0字节的文件 这看起来像x86.complete或x64.complete,只是表示 工具已正确安装在缓存中

我的测试目录结构:

$AGENT_TOOLSDIRECTORY/
    Python/
        3.9.0/
            x64/
                python-3.9.0-amd64.exe
            x64.complete

现在,它在我的自托管代理上运行良好:


您可以参考更多详细信息。

谢谢Leo。根据您的屏幕截图配置后,我能够成功运行管道。谢谢。在按照您的屏幕截图进行配置后,我能够成功运行管道。对于Ubuntu安装,请参阅以下答案:对于Ubuntu安装,请参阅以下答案: