Sorry if this is a real muppet question but I just started playing around with Python 2 days ago.
I'm interested in adding python support to a software I wrote in C++/Qt which does primary numerical stuff. Thus, it would be great to have python scripting support to extend the software with python scripts using numpy and pyqt to add dialogs.
My question therefore is whether this is possible to do through PythonQt?
I compiled all the sources without any probs and all tests are fine. However, I'm not able to load neither NumPy nor PyQt from a PythonQt console: I suspect it has something to do with sys.path under PythonQt since when using straight python everything works fine!?
Hello Everybody,
Sorry if this is a real muppet question but I just started playing around with Python 2 days ago.
I'm interested in adding python support to a software I wrote in C++/Qt which does primary numerical stuff. Thus, it would be great to have python scripting support to extend the software with python scripts using numpy and pyqt to add dialogs.
My question therefore is whether this is possible to do through PythonQt?
I compiled all the sources without any probs and all tests are fine. However, I'm not able to load neither NumPy nor PyQt from a PythonQt console: I suspect it has something to do with sys.path under PythonQt since when using straight python everything works fine!?
--------------------
Output in IDLE:
IDLE 2.6.1
>>> import sys
>>> sys.path
['C:\\Programme\\Python26\\Lib\\idlelib', 'C:\\Programme\\VTK\\lib\\site-packages', 'C:\\Programme\\Python26', 'C:\\WINDOWS\\system32\\python26.zip', 'C:\\Programme\\Python26\\DLLs', 'C:\\Programme\\Python26\\lib', 'C:\\Programme\\Python26\\lib\\plat-win', 'C:\\Programme\\Python26\\lib\\lib-tk', 'C:\\Programme\\Python26\\lib\\site-packages']
>>> from PyQt4 import QtGui
>>> app = QtGui.QApplication(sys.argv)
>>> from numpy import array
>>> a = array([[1,2,3],[4,5,6]])
>>> a.shape
(2, 3)
>>> a.dtype
dtype('int32')
>>>
--------------------
Output in PyhtonQt console:
py> import sys
py> sys.path
['C:\\Programme\\VTK\\lib\\site-packages', '', 'C:\\WINDOWS\\system32\\python26.zip', 'C:\\Programme\\Python26\\Lib', 'C:\\Programme\\Python26\\DLLs', 'C:\\Programme\\Python26\\Lib\\lib-tk', '', 'D:\\coding\\libs\\PythonQt-1.1\\lib']
py> from Qt4 import QtGui
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named Qt4
py> from numpy import array
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named numpy
------------------------
I'm using Visual Studio 2008 Pro with Qt4.5 and Python 2.5.1
Any help would be much appreciated.
Regards
Manfred
Ok, I know that this issue is 3 years old - so I leave this response for someone else who may come along searching…
1) from Qt4 import QtGui : should be
2) import numpy (fails)
assuming that that you have numpy installed and running (test with python.exe on windows)
When you init() PythonQt, you should leave out this flag: PythonQt::IgnoreSiteModule so that you can load modules from site-packages