subprocess.Popen: mkvirtualenv not found

后端 未结 2 981
轮回少年
轮回少年 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:09

    Edit:

    I learned that mkvirtualenv is a shell function. In this case the question becomes how to run shell function in python. My answer below can be applied to standalone binaries. For your question, please look at the answer: https://stackoverflow.com/a/5826523/1906700 You can indirectly call mkvirtualenv() function from the script that defines it.

    Set PATH variable correctly

    The problem seems to be caused by your $PATH variable. You need to correctly set this variable so that mkvirtualenv executable can be found. For example, if you have mkvirtualenv executable in `/home/thore/scripts, you need to set your $PATH in .bashrc or .zshrc (depending on your shell) as follows:

     export PATH=$PATH:/home/thore/scripts
    

    In that way, mkvirtualenv script will be found correctly and run.

    Another Solution

    The other solution to the problem would be using the exact path for the script in question. In that case, you can give /home/thore/scripts/mkvirtualenv as a parameter to subprocess.

提交回复
热议问题