15

(Mac)Vim seems to be picking up /usr/bin/python instead of the one that's at the front of my path (/Library/Frameworks/Python.framework/Versions/2.6/bin/python) when I use the :python command. Is this entirely a compile-time thing or can I somehow override it?

1 Answer 1

14

Seems like it is an entirely compile-time thing:

$ ldd /usr/bin/vim | grep python
libpython2.5.so.1.0 => /usr/lib/libpython2.5.so.1.0 (0xb6bcc000)

my vim --version also reports being built against a specific python.

$ vim --version | tr '-' '\n' | grep python
+python +quickfix +reltime +rightleft +ruby +scrollbind +signs +smartindent 
I/usr/include/python2.5 
L/usr/lib/python2.5/config 
lpython2.5 

another symptom of this is that the :python command won't work with vim unless vim --version reports +python.

Sign up to request clarification or add additional context in comments.

5 Comments

+1, correct, vim is indeed designed to use (embed) the Python library it's compiled and linked with (if any) -- which is also the normal way for any C or C++ application to embed Python, of course.
Thanks Paul, Alex. I've gone and recompiled MacVim, it turned out to be not as painful as I'd expected.
Note that Paul wrote what's probably the easiest way around this right now! I use ipython (installed for the system python) to send commands to an ipython kernel on the python I want to "use." python-mode or similar could support such behavior too (though it's heavy use of :python would require you to rewrite the run#Run function). This is really only a limitation for running things with :python, which you only need to do to script vim itself.
Looks like it's not the case now. I don't know the details. I just tried :python import sys; print sys.executable; and it is indeed affected by $PATH.
It is possible to use Python libraries from other locations by adding export PYTHONPATH="/home/user-name/anaconda3/lib/python3.5/site-packages":$PYTHONPATH to ~/.zshrc/. However, this does not change the interpreter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.