Page 1 of 2
import Pymaxwell PyThreadState_Get error
Posted: Wed Jun 10, 2015 7:00 pm
by lifeofdave
Hi All
So after a long break from OSX I've come back to package some maxwell scripts up for Mac, and I'm hitting an early early on.
I've installed python using homebrew 'brew install python', then copied pymaxwell.py and _pymaxwell.so to /usr/local/lib/python2.7/site-packages, but then when I try to import pymaxwell I get this error:
Fatal Python error: PyThreadState_Get: no current thread
Googling suggests the cause could be a conflict between the native OSX python and the installed python, but I'm still unsure how to go about fixing it. Any ideas anyone?
I'm gonna keep trying to fix this, but any pointers really appreciated..
Re: import Pymaxwell PyThreadState_Get error
Posted: Wed Jun 10, 2015 11:38 pm
by lifeofdave
similar problem with Macports and python 2.6 64bit:
>>> from pymaxwell import *
Fatal Python error: Interpreter not initialized (version mismatch?)
Abort trap: 6
Is pymaxwell compiled against apple's native python?
Re: import Pymaxwell PyThreadState_Get error
Posted: Thu Jun 11, 2015 11:41 am
by Brany
It is a known issue and we don't know how to fix it for now. We build pymaxwell against official releases of python (and the one included with osx) and it works for us.
Code: Select allmaxwell$ python
Python 2.7.5 (default, Mar 9 2014, 22:15:05)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path.insert(0,'/path/where/copied/Libs/pymaxwell/python2.7/pyandsofiles')
>>> import pymaxwell
>>> print(pymaxwell.Cmaxwell.getEngineVersion())
3.1.1.0
Please make sure that you're loading the right pymaxwell for python2.6/2.7. I just tried to load pymaxwell for python 2.6 from a python 2.7 console and I got the very same error you posted. You can check all paths in sys.path, maybe you have a pymaxwell.py/_pymaxwell.so files for an old installation
Code: Select allimport sys
for i in sys.path:
print i
Clean pymaxwell from all these paths so you be sure that python can't find pymaxwell, and then, copy pymaxwell in one of these listed paths from sys.path.
It is a good practice to avoid copying pymaxwell files into a system folder. It is dangerous because you can loose the track of where your pymaxwell modules are. I prefer to tell the sys modules where pymaxwell is by code:
Code: Select allimport sys
sys.path.insert(0,'/path/to/pymaxwell/modules')
import pymaxwell
Re: import Pymaxwell PyThreadState_Get error
Posted: Thu Jun 11, 2015 1:13 pm
by lifeofdave
Hi Brany
pymaxwell works for me using Apple's python included with OSX, but I can't get it to function with any other version of python. For basic scripts this isn't a problem, but for the project I'm currently working on I need to use PyQt and then bundle everything up using py2app, which I don't think is possible with Apple's modified/included python.
Apple Python (all good):
Code: Select allDaves-Mac:~ dave$ python
Python 2.7.3 (default, May 19 2013, 04:22:38)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.51)] on darwin
>>> import pymaxwell
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pymaxwell
>>> import sys
>>> sys.path.insert(0,'/Users/dave/Desktop/pymaxwell/python2.7')
>>> import pymaxwell
Macports python 2.6 (uho):
Code: Select allDaves-Mac:~ dave$ python2
Python 2.6.9 (unknown, May 25 2015, 13:02:23)
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> import pymaxwell
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pymaxwell
>>> sys.path.insert(0,'/Users/dave/Desktop/pymaxwell/python2.6')
>>> import pymaxwell
Fatal Python error: Interpreter not initialized (version mismatch?)
Abort trap: 6
Is there anything else I can try? Have you had success with pymaxwell and any python releases on OSX apart from the included apple one?
Thanks for your reply, it's a good first step to know it's a known issue!
Re: import Pymaxwell PyThreadState_Get error
Posted: Thu Jun 11, 2015 3:20 pm
by Brany
I suspect that in some point the system tries to use the default's system python loading pymaxwell, instead of the current python running one. In windows/linux we have no problem with this. Maybe there is a way to modify the _pymaxwell.so file, so it will link dinamically with the python_.so the user wants in an explicit way.
Re: import Pymaxwell PyThreadState_Get error
Posted: Thu Jun 11, 2015 5:59 pm
by lifeofdave
Yeah that would make sense. Is there anything I can do my end to either fix this or workaround it? Or does it require editing and recompiling by Next Limit?
Re: import Pymaxwell PyThreadState_Get error
Posted: Thu Jun 11, 2015 6:30 pm
by Brany
What version of OSX have you installed?
You are not able to load pymaxwell from the python that OSX delivers? Which version of python is, 2.6 or 2.7?
Did you search for all _pymaxwell.so in your system and removed it (all but the /Applications/Maxwell 3/Libs/pymaxwell...)?
Can you try to install python from here
https://www.python.org/downloads/?
Re: import Pymaxwell PyThreadState_Get error
Posted: Thu Jun 11, 2015 9:15 pm
by lifeofdave
I have OSX 10.9 installed. I am able to load pymaxwell from the python that comes with OSX, the problem is that the version of python already with OSX is not suitable for development generally, especially when it comes to using the pyqt libraries.
I have searched for _pymaxwell.so everywhere, it is not in any of the site-packages folders.
I just download python 2.7.10 from python.org, but unfortunately I still get this error:
Code: Select allPython 2.7.10 (v2.7.10:15c95b7d81dc, May 23 2015, 09:33:12)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path.insert(0,'/Users/dave/Desktop/pymaxwell/python2.7')
>>> import pymaxwell
Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6
anything else worth trying?
Re: import Pymaxwell PyThreadState_Get error
Posted: Mon Jun 15, 2015 5:15 pm
by Brany
Sorry, we have to do some research to find out what is happening here. We had other clients that tried to load pymaxwell in osx in other python distributions (anaconda), and even using that distribution headers and libs to build the pymaxwell module, the "Fatal Python error: PyThreadState_Get: no current thread" still happen.
Re: import Pymaxwell PyThreadState_Get error
Posted: Mon Jun 15, 2015 8:15 pm
by lifeofdave
Cool, a fix for this would mean huge amount to us. Without it we can't make our scripts work on osx.
Let me know if I can help test anything to help..
Re: import Pymaxwell PyThreadState_Get error
Posted: Thu Jul 16, 2015 2:14 pm
by Brany
There is a new build for the osx's pymaxwell:
https://drive.google.com/file/d/0B9ALOq ... sp=sharing
the "python2.7" folder should work with the python2.7.10 interpreter downloaded from python.org
Let us know if that version works, and if there are problems with other (2.6, 3.2 or 3.4).
Re: import Pymaxwell PyThreadState_Get error
Posted: Fri Jul 24, 2015 3:22 pm
by lifeofdave
I think the new build is working! Thank you!
Re: import Pymaxwell PyThreadState_Get error
Posted: Wed Jul 29, 2015 1:35 pm
by lifeofdave
Hi Brany
So the new build plays nicely with python 2.7.10 downloaded from
https://www.python.org/downloads/
however... when I try it with python 2.7.10 installed using homebrew I still get the same PyThreadState_Get error. I need to do a bit more research into this myself, but in the meantime wondered if you have any ideas, or if it's easy to build another pymaxwell against homebrew python 2.7.10?
Thanks for helping with the dreaded threadset error.. much appreciated!
Re: import Pymaxwell PyThreadState_Get error
Posted: Wed Jul 29, 2015 2:00 pm
by Brany
Did you tried with the python2.7-system version of pymaxwell?
Re: import Pymaxwell PyThreadState_Get error
Posted: Wed Jul 29, 2015 2:04 pm
by lifeofdave
Yes, sadly brew python doesn't work with it either