Using pyenv in a snakemake rule

Viewed 457

I am using snakemake for a long and complicated pipeline which involves some externally written python2 scripts. When I try to specify python2 with pyenv, pyenv shell command fails while pyenv global and pyenv local have no effect. I have two questions.

  • Why is the shell command absent? Is it because snakemake runs a non-login non-interactive shell?
  • Is it possible at all to switch to python2 in a snakemake rule using pyenv?

Here is an example Snakefile.

rule aaa:
   output:
      "aaa.txt"
   shell:
      """
      pyenv versions
      python --version
      echo "global"
      pyenv global 2.7.12
      python --version
      echo "local"
      pyenv local 2.7.12
      python --version
      echo "shell"
      pyenv shell 2.7.12
      python --version
      echo "pa-pa, zlyj svite" > aaa.txt
      """

That produces the following output.

...
rule aaa:
    output: aaa.txt
    jobid: 0

  system
  2.7.12
  3.5.2
* 3.6.1 (set by PYENV_VERSION environment variable)
Python 3.6.1
global
Python 3.6.1
local
Python 3.6.1
shell
pyenv: no such command `shell'
Error in job aaa while creating output file aaa.txt.
...
1 Answers
Related