Crash when using vim with Python 3.7 (both compiled from source) - PyThreadState_Get: no current thread

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

Crash when using vim with Python 3.7 (both compiled from source) - PyThreadState_Get: no current thread

Jonathan Crall
I'm not sure if this is a vim issue or a python 3.7 issue.

I have compiled both vim and python 3.7 from source. Whenever
I try to execute a python3 block in a vim script I get the following crash:

Fatal Python error: PyThreadState_Get: no current thread

Vim: Caught deadly signal ABRT
Vim: Finished.
Aborted (core dumped)

Doing some googling I find that this question has been asked in the context of YouCompleteMe and MacVim, but I'm on Ubuntu 16.04 and I'm not using any plugins. I do have multiple versions of python and vim on my system, so I'm wondering if libraries might potentially be getting confused. I'll do my best to explain my setup.

Because I'm on Ubuntu 16.04 I have python3.5 installed to the system (in /usr/bin/python3.5). I want to upgrade to 3.7, so I decided I would install that locally to override the system default. So, I cloned the source and installed a new build into ~/.local.

Here is how I installed python 3.7
cd ~/code
git clone

export NCPUS=$(grep -c ^processor /proc/cpuinfo)
export PREFIX=$HOME/.local
cd ~/code/cpython

./configure --prefix=$PREFIX --exec-prefix=$PREFIX \
    --enable-shared --enable-ipv6 --enable-loadable-sqlite-extensions --with-fpectl \
    --with-dbmliborder=bdb:gdbm --with-computed-gotos --with-ensurepip --with-threads \
    'CFLAGS=-g -fstack-protector-strong -Wformat -Werror=format-security ' \
    'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro' \
    'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2'

make -j$NCPUS
make install
This build seems to work fine for all my normal python use-cases (except when it comes to vim-scripts).

Then I did the same for vim.

git clone
cd ~/code/vim
./configure \
        --prefix=$HOME/.local \
        --enable-pythoninterp=no \
        --enable-python3interp=yes \
        --with-python3-config-dir=$(python3.7-config --configdir) \
cat src/auto/ | grep PYTHON3
make -j9

Note, I have previously built vim to target the system python3.5 and everything works fine, but when linking to 3.7 I encounter a problem. I made a test file:

python3 << EOF
import sys
And when I run this test `./src/vim -u NONE --cmd "source test.vim"`  after building vim. I get the PyThreadState_Get error. If I revert back to my old vim build (which was linked to python 3.5) the test correctly prints hello.

So, I'm at a bit of a loss as to what could be going wrong. For now I'm just going to have to switch back to 3.5, because I depend heavily on having python scripting in my vimrc. For additional information here are my envvars and the vim and python specs:



./src/vim --version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Mar 27 2017 10:35:20)
Included patches: 1-514
Compiled by joncrall@hyrule
Huge version with GTK3 GUI.  Features included (+) or not (-):
+acl             +file_in_path    +mouse_sgr       +tag_old_static
+arabic          +find_in_path    -mouse_sysmouse  -tag_any_white
+autocmd         +float           +mouse_urxvt     -tcl
+balloon_eval    +folding         +mouse_xterm     +termguicolors
+browse          -footer          +multi_byte      +terminfo
++builtin_terms  +fork()          +multi_lang      +termresponse
+byte_offset     +gettext         -mzscheme        +textobjects
+channel         -hangul_input    +netbeans_intg   +timers
+cindent         +iconv           +num64           +title
+clientserver    +insert_expand   +packages        +toolbar
+clipboard       +job             +path_extra      +user_commands
+cmdline_compl   +jumplist        -perl            +vertsplit
+cmdline_hist    +keymap          +persistent_undo +virtualedit
+cmdline_info    +lambda          +postscript      +visual
+comments        +langmap         +printer         +visualextra
+conceal         +libcall         +profile         +viminfo
+cryptv          +linebreak       -python          +vreplace
+cscope          +lispindent      +python3         +wildignore
+cursorbind      +listcmds        +quickfix        +wildmenu
+cursorshape     +localmap        +reltime         +windows
+dialog_con_gui  -lua             +rightleft       +writebackup
+diff            +menu            -ruby            +X11
+digraphs        +mksession       +scrollbind      -xfontset
+dnd             +modify_fname    +signs           +xim
-ebcdic          +mouse           +smartindent     +xpm
+emacs_tags      +mouseshape      +startuptime     +xsmp_interact
+eval            +mouse_dec       +statusline      +xterm_clipboard
+ex_extra        +mouse_gpm       -sun_workshop    -xterm_save
+extra_search    -mouse_jsbterm   +syntax          
+farsi           +mouse_netterm   +tag_binary      
   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: "/home/joncrall/.local/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/mirclient -I/usr/include/mircommon -I/usr/include/mircookie -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include   -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      
Linking: gcc   -L/usr/local/lib -Wl,--as-needed -o vim   -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lSM -lICE -lXpm -lXt -lX11 -lXdmcp -lSM -lICE  -lm -ltinfo -lnsl  -lselinux  -lacl -lattr -lgpm -ldl     -L/home/joncrall/.local/lib/python3.7/config-3.7m-x86_64-linux-gnu -lpython3.7m -lpthread -ldl -lutil -lm      


I'd really appreciate any insight into whats going on. Let me know if I need to provide more info.

You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit

You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit