• Register
0 votes
184 views

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

Then,

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:

https://github.com/facebookarchive/caffe2/issues/854

36.1k points
edited by
0 votes

Solution:

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

 

17.7k points
edited by

Related questions

0 votes
1 answer 20 views
20 views
Problem: I am very new to Keras. Now a days I am trying to use Keras (Sequential) but I am facing below error if I try to import it: File "kaggle_titanic_keras.py", line 3, in <module>     from keras.models import Sequential  File "/anaconda/lib/python2.7/site- ... 2.0.3 and recently 'upgraded' to Pandas 0.20.1 which I doubt is causing a problem but above error message says nothing about it.
asked Jul 21 Raphael Pacheco 3.2k points
0 votes
1 answer 8 views
8 views
Problem: I have recently started learning python. Now to do practical on python I am trying to install the python onto my homebrew. Python got downloaded and after that the error message popped up at the end of installation and it stopped it from completing. If I try to ... sudo chown -R $(whoami) /usr/local And nowI get the error message which reads as: chown: /usr/local: Operation not permitted
asked Jul 28 Raphael Pacheco 3.2k points
1 vote
1 answer 45 views
45 views
Problem: Hello good soul, I have recently come to know with python &ldquo;lxml&rdquo; 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&rsquo;s wrong in my procedure? Could you please figure it out? Thanks.
asked May 18 adamSw 11.3k points
1 vote
1 answer 32 views
32 views
Problem: I am using a MacBook pro for my python development work. Right now I&rsquo;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&rsquo;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 11.3k points
1 vote
1 answer 154 views
154 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&rsquo;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&rsquo;ll solve the problem and save my time. Thanks.
asked May 18 adamSw 11.3k points