macvim/python loads the wrong Python libraries
This ticket is probably related to Homebrew/homebrew issues #26426, #17908, #20075, #20392. I tried the following with vim 7.4 (brew version) and macvim release 83.
With vim
:!which python
/usr/local/bin/python
:py import itertools
:py import os; print os.__file__
/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.pyc
With macvim
:!which python
/usr/local/bin/python
:py import itertools
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named itertools
:py import os; print os.__file__
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.pyc
Workarounds
brew unlink python but that is not what I would call a fix.
Also, when I launch macvim from a virtualenv, things work ok!
Updated https://github.com/macvim-dev/macvim/releases/tag/snapshot-84
https://s3.amazonaws.com/archive.travis-ci.org/jobs/92834400/log.txt
-DDYNAMIC_PYTHON_DLL=\"/System/Library/Frameworks/Python.framework/Versions/2.7/Python\"
If I change python3dll and create symlink to /Libraries/Framework/.. etc, it able to load correct Python 3.5.
So the problem I see is MacVim (vim?) doesn't initialise correctly Python when it is placed in place with other base than all Python Home specified in configure.
I haven't tested with removing Python2.7 from system (in any way like chmod/mv/rm), but we should start to look in difference of Python2 and Python 3 initialisation. And we should change both if initialisation depends only on predefined variables but not in python3dll and pythondll.
@splhack setting PYTHONPATH environment is not work in any way
As I said, it is Vim issue not MacVim issue. Please go to Vim issues or Vim mailing list.
The master branch included $PYTHONHOME fix _experimentally_. It may be changed in the future, and, still, it is Vim issue, please go to Vim issues or Vim mailing list if you want to discuss about it.
Hi, I still have same issue with MacVim running on Mojave, (/Applications/MacVim.app/Contents/bin/vim)
Build it without python3 fix the problem.
brew reinstall -s --with-python@2 --without-python macvim
Details for macvim that come from brew bottle:
Press ENTER or type command to continueVim: Caught deadly signal ABRT
Vim: Finished.
fish: 'vim' terminated by signal SIGABRT (Abort)
$ brew list | grep python
python
python-markdown
python@2
The issue is not preset when i'm using build-in vim (/usr/bin/vim):
:version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Aug 17 2018 15:22:29)
Included patches: 1-503, 505-680, 682-1283
Compiled by [email protected]