Sunday 15 April 2012

Python import failed for PyQt4 -



Python import failed for PyQt4 -

i trying utilize "imp" library export symbols of pyqt4. utilize built-in "import pyqt4.qtcore" ok, python's code failed. test basing on mac. on windows, seems if set 1 "init.py" (empty file ok) under qtcore directory, "import qtcore" success. on mac, unknown reason, failed. in cli:

bash-3.2# 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" more information. >>> import pyqt4.qtcore f >>> print f.__file__ /library/python/2.7/site-packages/pyqt4/qtcore.so

however, usage failed.

bash-3.2# cd /library/python/2.7/site-packages/pyqt4/ bash-3.2# 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" more information. >>> import qtcore traceback (most recent phone call last): file "<stdin>", line 1, in <module> systemerror: dynamic module not initialized

can explains it?

qtcore cannot straight imported python. qtcore exists in pyqt4 library. access qtcore class need next :

python 2.7.8 (default, jun 30 2014, 16:03:49) [msc v.1500 32 bit (intel)] on win32 type "copyright", "credits" or "license()" more information. >>> pyqt4 import qtcore >>>

the __init__.py files required create python treat directories containing packages; done prevent directories mutual name, such string, unintentionally hiding valid modules occur later on module search path. in simplest case, __init__.py can empty file, can execute initialization code bundle or set __all__ variable, described later.

python import pyqt4

No comments:

Post a Comment