macvim icon indicating copy to clipboard operation
macvim copied to clipboard

macvim/python loads the wrong Python libraries

Open xoolive opened this issue 11 years ago • 26 comments

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!

xoolive avatar Nov 22 '15 16:11 xoolive

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\"

splhack avatar Nov 24 '15 00:11 splhack

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.

eirnym avatar Nov 24 '15 11:11 eirnym

@splhack setting PYTHONPATH environment is not work in any way

eirnym avatar Nov 24 '15 11:11 eirnym

As I said, it is Vim issue not MacVim issue. Please go to Vim issues or Vim mailing list.

splhack avatar Nov 24 '15 18:11 splhack

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.

splhack avatar Dec 04 '15 07:12 splhack

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]

t0d0r avatar Sep 27 '18 13:09 t0d0r