$ mvim
:py3 print('hello world')
kills macvim and returns on the command line
Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00007fffbd48e3c0 (most recent call first):
Vim: Caught deadly signal ABRT
Vim: Finished.
I run into this issue constantly. In the past I could fix it by installing the correct python version for the pre-compiled macvim app.
According to the release notes for MacVim releases 150 and 151, the correct python3 version should
be 3.7(.0).
However, upgrading python 3.6.4_2 with homebrew to 3.7.0 and installing release 151 (8.1.280), ultisnips kills my macvim again.
I do not want to install macvim via homebrew as suggested in #649. Other issues are #554.
I also noticed that a necessary change has been overlooked in src/MacVim/vimrc
" Python3
" MacVim uses Homebrew python3 if installed, next try to use python.org binary
if exists("&pythonthreedll") && exists("&pythonthreehome") &&
\ !filereadable(&pythonthreedll)
if filereadable("/Library/Frameworks/Python.framework/Versions/3.6/Python")
" https://www.python.org/downloads/mac-osx/
set pythonthreedll=/Library/Frameworks/Python.framework/Versions/3.6/Python
set pythonthreehome=/Library/Frameworks/Python.framework/Versions/3.6
endif
endif
It still would use python 3.6 from python.org if installed (this is not the case on my machine).
Everything works with MacVim.dmg v149 and python 3.6.4_2.
I have the same version of MacVim and explicitly set paths to Python 3.7 from MacPorts without checking any other installations.
The official vim/vim setup guide asks user to set dll to dylib, not to Python app itself. and I don't know if it could also work. If this is an issue then
set pythonthreehome=/opt/local/Library/Frameworks/Python.framework/Versions/3.7
set pythonthreedll=/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/libpython3.7.dylib
set pythonhome=/opt/local/Library/Frameworks/Python.framework/Versions/2.7
set pythondll=/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib
" disable Python 2 as soon as possible
py3 1+2
pyx 1+2
@kiryph On the snipped you provided, it's really overlooked and I vote to add Python paths from MacPorts as well.
@eirnym Thank you very much.
I have forgotten that I had already added this line to my vimrc and did not update it. SORRY for my stupidity. It works now.
You're welcome
Most helpful comment
I have the same version of MacVim and explicitly set paths to Python 3.7 from MacPorts without checking any other installations.
The official vim/vim setup guide asks user to set dll to dylib, not to Python app itself. and I don't know if it could also work. If this is an issue then