首页 > 解决方案 > python3-venv在项目中的安装位置

问题描述

我正在使用 jenkins 文件来运行烟雾测试

def runSmokeTest(environment) {
    docker.image("python:3.7").inside {
        withCredentials([usernamePassword(credentialsId: "inhome_smoketest_authz_${environment}",
         usernameVariable: 'CLIENT_ID', passwordVariable: 'CLIENT_SECRET')]) {
            sh "make smoketest CLIENT_ID=$CLIENT_ID CLIENT_SECRET=$CLIENT_SECRET ENV=${environment}"
        }
    }
}

我在其中遇到错误

make smoketest CLIENT_ID=**** CLIENT_SECRET=**** ENV=acceptance
The virtual environment was not created successfully because ensurepip is not
available.  On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.

    apt-get install python3-venv

You may need to use sudo with that command.  After installing the python3-venv
package, recreate your virtual environment.

Failing command: ['/u01/app/jenkins/masters/jenkins-de-bcn-team-jenkins-master-6d64469c64-d5r87/workspace/de-inhome-smoketest/venv/bin/python3.7', '-Im', 'ensurepip', '--upgrade', '--default-pip']

为了创建虚拟环境,我们使用 Makefile 如下

$(VENV_BASE):
    @rm -rf venv
    @$(PYTHON_VERSION) -m venv venv
    @touch $@

对于冒烟测试,我们在 Makefile 中编写了以下代码

.PHONY: smoketest
smoketest: $(VENV_PROD)
    venv/bin/python src/manage.py smoke_test --client_id=$(CLIENT_ID) --client_secret=$(CLIENT_SECRET) --env=$(ENV)

你能帮我在哪里安装python3-venv吗?

标签: python-3.xdockerjenkinsjenkins-pipeline

解决方案


推荐阅读