0

Problem having two versions of python on my Mac and them interacting. I have the following python locations

python is /anaconda3/envs/fenicsproject/bin/python

python is /usr/bin/python

and when I try to run a script. I get the following error:

Fatal Python error: PyThreadState_Get: no current thread

Abort trap: 6

I have googled some solutions and have found some posts saying I should try

env PYTHON_CONFIGURE_OPTS="--enable-framework"  #or 
env PYTHON_CONFIGURE_OPTS="--enable-shared" 

This is they type of code I try to run

#Import packages 
import dolfin as dl

I installed the env fenics by following the directions here

2 Answers 2

1

The google search possibly found Homebrew + Python on mac os x 10.8: Fatal Python error: PyThreadState_Get: no current thread importing mapnik however I was unable to find the library that links to a wrong version of python using otool.

I also found https://github.com/enthought/mayavi/issues/552 which suggests pinning to a different version of python.

Based on the install notes for hippy, https://hippylib.readthedocs.io/en/latest/installation.html then where they say conda create -n fenicproject ... you need to substitute the following:

conda create -n fenicsproject python==3.5.1
conda install -n fenicsproject -c conda-forge fenics==2017.2.0 \
               mpi4py matplotlib scipy sympy==1.1.1 jupyter

After this, python -c 'import dolfin' no longer fails. It might also be possible to use a later version of python (I only tried 3.5.1).

Sign up to request clarification or add additional context in comments.

18 Comments

I think it is the dolphin. I will try it and update shortly
It did not help :(
Try looking through the suggestions in the link starting with the otool command.
If you want further help, can you give more detail about where you are installing dolfin from and if something like python -c import dolfin reproduces the problem.
when I copy and paste python -c import dolfin I get the error. File "<string>", line 1 import ^ SyntaxError: invalid syntax
|
0

What OS are you using? That will largely determine the specifics of how to go about correcting this issue, but the key here is which Python version the system path points to and what Python version your IDE is pointing to.

What you largely want to avoid is a situation where you are running Python scripts via your native system Python (2, likely).

Check which version of Python your IDE is using (from: How do I check what version of Python is running my script?):

import sys
print(sys.version)

Is the first number a 2? Did you want to use Python 2?

Next, let's check what version your system currently defaults to. If Ubuntu/Linux, use:

python -V

Is this expected? If not, you may need to change your system environmental variables to point to the correct Python version. The solution to this is OS dependent. If Windows, search "Edit Environmental Variables for Your Account" -> "Environmental Variables" -> "Path" , be sure it either points to Anaconda or the correct Python version; if Ubuntu/Linux, check your .bashrc file:

gedit ~/.bashrc

to see if the system points to the correct Python variable. If using a Mac, I formally apologize.

2 Comments

Mojave 10.14.5 and the python is 3.6.7 | packaged by conda-forge | (default, Feb 28 2019, 02:16:08) [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]
And the default python is Python 3.6.7 . Which is what I want to use, I think the problem arises only when I call the dolfin

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.