I'm having a bit of trouble with running scripts with python-mode while in a specific conda virtual environment.

I've installed spf13 & an additional plugin (vim-conda) which allows to change conda virtual environment inside vim. vim-conda works exactly as it's supposed to:

:CondaChangeEnv py35
:!python %

executes my Python script in shell with libraries specific to py35 environment

But if i use :PymodeRun (from python-mode) to run the same script it throws an error which says that it's unable to find libraries I mentioned above.

Running :echo system("python -V") show proper version of Python (different for different conda environments)

Any help on how to explore this will be greatly appreciated. Thanks in advance!

  • What is :PymodeRun? That's not a standard command or part of the vim-conda plugin as far as I can see. Judging from the error, it sounds like that is trying to run :python and not :!python? – Martin Tournoij Aug 12 '16 at 9:57
  • Thank you for the edits :) Looks much nicer now. :PymodeRun is a command that python-mode.vim uses to execute python scripts. Does :python depends on the current enviroment? If not, then I probably should search for another way to run python scripts from vim: run :!python % in a tmux split or somehing... – Eralde Aug 12 '16 at 10:40
  • A quick look at the python-mode plugin indeed reveals that this uses :python. When you use :python Vim uses libpython and not the /bin/python binary. I think that in recent versions Vim introduced some settings to control which library it uses but I haven't had time to investigate how this works yet (see :help 'pythondll'). Also note that in Neovim the Python script support was revamped, and I believe that DOES use the /bin/python binary. – Martin Tournoij Aug 12 '16 at 10:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.