subprocess.Popen: mkvirtualenv not found

后端 未结 2 983
轮回少年
轮回少年 2020-12-11 20:42

I\'m using virtualenvwrapper in my deployment. To setup new environments, I\'m running a python script, which contains all needed steps.

The setupscript includes:

2条回答
  •  遥遥无期
    2020-12-11 21:16

    mkvirtualenv might be a shell function that is added to your environment by sourcing virtualenvwrapper.sh script from your shell's startup file. The default command invoked on shell=True (e.g., /bin/sh -c ...) might not read it.

    You could source the file explicitly:

    import pipes
    from subprocess import check_call
    
    check_call("""source /path/to/virtualenvwrapper.sh &&
        mkvirtualenv --no-site-packages """ + pipes.quote(envname),
        executable='bash', shell=True)
    

提交回复
热议问题