Spacevim: Fatal Python error: Py_Initialize: unable to load the file system codec

Created on 19 Jan 2018  ·  7Comments  ·  Source: SpaceVim/SpaceVim

Expected behavior, english is recommended

Environment Information

  • OS: osx 10.13.2 + zsh + oh-my-zsh
  • vim version: VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jul 25 2017 05:00:22)
  • neovim version:

The reproduce ways from Vim starting (Required!)

line 6: sourcing "/Users/xiaolei/.vim/autoload/SpaceVim/api/vim/compatible.vim"
finished sourcing /Users/xiaolei/.vim/autoload/SpaceVim/api/vim/compatible.vim
continuing in function SpaceVim#api#import
finished sourcing /Users/xiaolei/.vim/autoload/SpaceVim/api/file.vim
continuing in function SpaceVim#api#import
Searching for "autoload/SpaceVim/util.vim" in "/Users/xiaolei/.vim,/Applications/MacVim.app/Contents/Resources/vim/vimfiles,/Applications/MacVim.app/Contents/Resources/vim/runtime,/Applications/MacVim.app/Contents/Resources/vim/vimfiles/after,/Users/xiaolei/.vim/after"
Searching for "/Users/xiaolei/.vim/autoload/SpaceVim/util.vim"
chdir(/Users/xiaolei/.vim/autoload/SpaceVim)
fchdir() to previous dir
line 101: sourcing "/Users/xiaolei/.vim/autoload/SpaceVim/util.vim"
finished sourcing /Users/xiaolei/.vim/autoload/SpaceVim/util.vim
continuing in /Users/xiaolei/.SpaceVim/autoload/SpaceVim.vim
Fatal Python error: Py_Initialize: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007fffb0fec340 (most recent call first):
Vim: Caught deadly signal ABRT

Writing viminfo file "/Users/xiaolei/.viminfo"Vim: Finished.

[2] 28604 abort vim -V

Output of the ':SPDebugInfo!'

please post log below, if you want me to reproduce your issue quickly, including your custom config here will be better.

Screenshots

If you have any screenshots for this issue, please upload here. BTW you can use https://asciinema.org/ for recording video in terminal.

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jul 25 2017 05:00:22)
MacOS X (unix) version
Included patches: 1-771
Compiled by [email protected]
Huge version with MacVim GUI. Features included (+) or not (-):
+acl +find_in_path -mouse_sysmouse -tag_any_white
+arabic +float +mouse_urxvt -tcl
+autocmd +folding +mouse_xterm +termguicolors
+balloon_eval -footer +multi_byte +terminal
+browse +fork() +multi_lang +terminfo
++builtin_terms +fullscreen -mzscheme +termresponse
+byte_offset -gettext +netbeans_intg +textobjects
+channel -hangul_input +num64 +timers
+cindent +iconv +odbeditor +title
+clientserver +insert_expand +packages +toolbar
+clipboard +job +path_extra +transparency
+cmdline_compl +jumplist +perl/dyn +user_commands
+cmdline_hist +keymap +persistent_undo +vertsplit
+cmdline_info +lambda +postscript +virtualedit
+comments +langmap +printer +visual
+conceal +libcall +profile +visualextra
+cryptv +linebreak +python/dyn +viminfo
+cscope +lispindent +python3/dyn +vreplace
+cursorbind +listcmds +quickfix +wildignore
+cursorshape +localmap +reltime +wildmenu
+dialog_con_gui +lua/dyn +rightleft +windows
+diff +menu +ruby/dyn +writebackup
+digraphs +mksession +scrollbind -X11
+dnd +modify_fname +signs -xfontset
-ebcdic +mouse +smartindent +xim
+emacs_tags +mouseshape +startuptime -xpm
+eval +mouse_dec +statusline -xsmp
+ex_extra -mouse_gpm -sun_workshop -xterm_clipboard
+extra_search -mouse_jsbterm +syntax -xterm_save
+farsi +mouse_netterm +tag_binary
+file_in_path +mouse_sgr +tag_old_static
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
system gvimrc file: "$VIM/gvimrc"
user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
defaults file: "$VIMRUNTIME/defaults.vim"
system menu file: "$VIMRUNTIME/menu.vim"
fall-back for $VIM: "/Applications/MacVim.app/Contents/Resources/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MACVIM -Wall -Wno-unknown-pragmas -pipe -DMACOS_X_UNIX -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: clang -L. -fstack-protector -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L. -fstack-protector -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L/usr/local/lib -o Vim -framework Cocoa -framework Carbon -lm -lncurses -liconv -framework Cocoa -fstack-protector -L/System/Library/Perl/5.16/darwin-thread-multi-2level/CORE

Most helpful comment

It's not about SpaceVim.
The whole solution comes from this. Try to read them

Solution 1

You may want to check this: click me
Do this:

PYTHONHOME=/usr/local/Cellar/python3/3.x.y/Frameworks/Python.framework/Versions/3.x
PYTHONPATH=$PYTHONHOME/bin

Solution 2

  1. brew install python3
  2. cd /usr/local/bin
  3. rm python3
  4. ln -s /usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/‌​Versions/3.6/bin/pyt‌​hon3.6 /usr/local/bin/python3
    Then it should work.

Reference

All 7 comments

It's not about SpaceVim.
The whole solution comes from this. Try to read them

Solution 1

You may want to check this: click me
Do this:

PYTHONHOME=/usr/local/Cellar/python3/3.x.y/Frameworks/Python.framework/Versions/3.x
PYTHONPATH=$PYTHONHOME/bin

Solution 2

  1. brew install python3
  2. cd /usr/local/bin
  3. rm python3
  4. ln -s /usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/‌​Versions/3.6/bin/pyt‌​hon3.6 /usr/local/bin/python3
    Then it should work.

Reference

@Gabirel Thanks.

brew default install multiple python3, Uninstall all python3, ok!
@Gabirel thank you very much

@goodleixiao nice!

@Gabirel THANK YOU! God. I spent all morning on this. You are the best ❤️

This is in my bashrc now, which fixed it (future readers will need to tweak that path probably):

export PYTHONHOME=/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/
export PYTHONPATH=$PYTHONHOME/bin

I don't know if it matters but I brew uninstalled python, python3, python2, and macvim before reinstalling macvim and doing this.

brew uninstall --force python
brew install python3
worked for me

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gennad picture gennad  ·  4Comments

eperfect picture eperfect  ·  4Comments

wsdjeg picture wsdjeg  ·  3Comments

zeroasterisk picture zeroasterisk  ·  4Comments

s97712 picture s97712  ·  4Comments