This is a Python 2.7 question. I have a custom python 2.7, that I have compiled and have been using successfully across my system. My custom python has the YAML modules installed as well.The system wide Python 2.7 is in it's usual path on OSX:/System/Library/Frameworks/Python.framework/Versions/2.7/function! MyPythonFunction() abort    echo a:testString    python << EOF    import yaml    print yaml    print PYTHON: My Python function.    EOF    return 1endfunctionWhen I run a Python based function as the one above, I can see that the system wide Python2.7 is active. So for that reason my YAML import fails, as I do not have YAML installed under my system Python.Is there a way to tell VIM to use my custom Python2.7 that lives inside:/Users/me/apps/Darwin64/python2.7/or somehow call my custom YAML module?I have done a bit of research and I think there are things that I can tweak through VIM's Python modules (import vim) and there is a Python2 rtp config. However I am not sure how to set those up.Thanks.
How to access a custom python module inside vim?
vimscript;vimscript python
Here is the answer to this question, however, first things first:I do not use macports or brew.The ideal workflow for me would be to download the source code of any package, module, library or app and compile it myself.For those reasons listed above, brew was not an option for me. So here is the solution:export CC=clang # Will be assumed automatically, most of the timesexport vi_cv_path_python=/Users/me/apps/Darwin64/python2.7/bin/pythonexport vi_cv_dll_name_python=/Users/me/apps/Darwin64/python2.7/lib/libpython2.7.dylibexport DYNAMIC_PYTHON_DLL=/Users/me/apps/Darwin64/python2.7/lib/libpython2.7.dylib./configure --with-features=huge \    --enable-cscope=yes \    --enable-pythoninterp=yes \    --enable-rubyinterp=yes \    --enable-perlinterp=yes \    --enable-luainterp=yes \    --with-lua-prefix=/Users/me/apps/Darwin64/lua-5.2.3-clang-500.2.79 \    --with-python-config-dir=/Users/me/apps/Darwin64/python2.7/lib/python2.7/config \    --with-compiledby=Symbolix(Some of the ENV variables above, might not be necessary. I not sure about what I did regarding the $PYTHONHOME and $DYLD_LIBRARY_PATH variables. As far as I remember, those were not important for the above command to be successful. You might need to have your custom Python at the front of your $PATH variable though.)Please note that I am linking against my own custom lua.Then:makecd ./MacVim/build/Release/open MacVim.appcp -vr MacVim.app /Applications/This worked for me on OSX 10.10.5 and VIM 7.4.1553 and I can confirm that VIM is linked properly against my own version of Python2.7. When I type: :py import yaml; print yaml I get the following:<module 'yaml' from '/Users/me/apps/Darwin64/python2.7/lib/python2.7/site-packages/yaml/__init__.pyc'>I am still testing this and it seems to be stable and working so far. Now, I am not depending on System Python and I can take care of my own packages etc. If something breaks, I will let you know. Also I do not need to alter any of the sys.path or in fact I do not need to do anything extra to access my own python and the modules inside.One important aspect is that if you run into trouble compiling this, make sure that you have the latest Xcode and you have run xcode-select --install before compiling VIM from source. If things are still not working make sure to check the build log inside ./src/auto/config.log everything that you need to debug your build process is in there. Good luck.