• Register
Log In
0 votes

Problem :

 When I open python and enter import mapnik, the following error comes and python exits:
>>> import mapnik
Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6
6.9k points

2 Answers

0 votes

Solution :

I have faced the same problem between python27-apple and python27. 

I followed bellow steps and it worked for me:

sudo port select --list python


sudo port select python python27-apple

 To double check,

sudo port select --list python

And the python crash had gone when I ran the scripts.

Further Readings:


36.1k points
edited by
0 votes


This issue may happen in case the .so file from homebrew's formula links against a different python library than the interpreter you are running, view also this thread and this response.

In case you have no other dependencies then running your program employing the python interpreter from homebrew (which must be located in /usr/local/bin/) may solve the problem.

And you'll possibly require to employ the install_name_tool to point the library to the right python like this:

sudo install_name_tool -change libpython2.7.dylib ~/anaconda/lib/libpython2.7.dylib /usr/local/caffe2/python/caffe2_pybind11_state.so

This is occured by linking a static version of libpython into ycmd's ycm_core.so. This leads to multiple copies of the python interpreter loaded at the time python loads ycmd_core. Hence and this messes up python's global state. The details aren't significant.

The solution is that the version of Python linked and run against should be built with either --enable-shared or --enable-framework (on OS X). This is acquired as follows (NOTE: for Mac, replace --enable-shared with --enable-framework):

At the time building python from source: ./configure --enable-shared {options}
At the time building python from pyenv: PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install {version}

I got the cause: cmake-3.5 with GUI compile SimpleElastix by python-app which is a pre-installed version by OS-X, however the excute python in my command line is installed by homebrew or pyenv or macport or anything else. After failed employing otool -L and install_name_tool to switch dynmaic link library, i pursue this post to switch python by myself:

1.Delete old python version by OS-X:

sudo mv /System/Library/Frameworks/Python.framework/Versions/2.7 /System/Library/Frameworks/Python.framework/Versions/2.7_bak
  1. Move the new python:

sudo mv /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7 /System/Library/Frameworks/Python.framework/Versions/2.7

3.Setting group to wheel if required:

sudo chown -R root:wheel /System/Library/Frameworks/Python.framework/Versions/2.7
  1.  4.  Updating the current link if required:

sudo rm /System/Library/Frameworks/Python.framework/Versions/Current sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.7 /System/Library/Frameworks/Python.framework/Versions/Current


12.8k points
edited by

Related questions

1 vote
1 answer 27 views
Problem: Hello good soul, I have recently come to know with python “lxml” module. I was willing to use this toolkit in my python script. Thus I wrote from lxml import etree ImportError: No module named lxml and got that above error. Then I ... the development packages of libxml2 and libxslt are installed ** What’s wrong in my procedure? Could you please figure it out? Thanks.
asked May 18 adamSw 8.3k points
1 vote
1 answer 23 views
Problem: I am using a MacBook pro for my python development work. Right now I’ve installed the nltk module on my machine by following a tutorial on YouTube. once I am trying to import the module in my script it’s producing an error of: ImportError: No module ... . Do you know I am having this kind of error? Please, pull me up from this problem. I appriciate your concern Thanks, mate.
asked May 18 adamSw 8.3k points
1 vote
1 answer 58 views
Problem: Hello there, I am using Python 3.5 in my Ubuntu 18.04 LTS based computer. I am trying to import a module named openpyxl in my script but somehow it’s not happening for me. It says, module not found error: no module named 'openpyxl' Traceback ... the solution to this specific issue. Therefore, I come to this forum. Hopefully, you’ll solve the problem and save my time. Thanks.
asked May 18 adamSw 8.3k points
1 vote
1 answer 18 views
Problem: Hello Kodlogs, Could any of you, please tell me what is module not found error: no module named 'quandl' error? I am trying to import the quandl module in Python-3.5.2 but it’s not working in my case and produces an error. Here is the error I ... on my Ubuntu-based machine. Could you please find the error and give me a legit solution? I am looking forward to hearing for you. Thanks.
asked May 18 adamSw 8.3k points
0 votes
1 answer 839 views
Problem : Following is my issue: I tried to install mysqlclient like below : C:\Users\alecxe>pip install mysqlclient Collecting mysqlclient Using cached https://files.pythonhosted.org/packages/ec/fd/83329b9d3e14f7344d1 cb31f128e6dbba70c5975c9e57896815dbb1988ad/mysqlclient-1.3.13.tar.gz Installed ... beginner to this and would be very happy if any input as to how to go about fixing above error.
asked Dec 27, 2019 alecxe 7.5k points