简体   繁体   中英

Why is there an ImportError in PyQt5 with Python 3.4.3 and PyCharm?

I want to use PyQt5 library in PyCharm using Python 3.4.3. I had all the programs installed, but instead of working fully, PyCharm occurs error:

C:\Python34\python.exeC:/Python34/Lib/sitepackages/PyQt5/examples/dbus/listnames.py
Traceback (most recent call last):
File "C:/Python34/Lib/site-packages/PyQt5/examples/dbus/listnames.py", line 47, in <module>
from PyQt5.QtCore import QCoreApplication
ImportError: DLL load failed: %1 is not a valid Win32 application.

Process finished with exit code 1

and my code is simply this, which I am importing a model to PyCharm from PyQt5 for creating a simple window:

import sys
from PyQt5 import QtGui

def main():
    app = QtGui.QApplication(sys.argv)
    w = QtGui.QWidget()
    w.resize(250, 150)
    w.move(300, 300)
    w.setWindowTitle('Simple')
    w.show()

    sys.exit(app.exec_())

if __name__ == '__main__':
    main()

This error only shows up when I use PyCharm, not in Portable Python. So can someone shows me how to setup PyCharm using Python 3.4.3 and PyQt5? If that is not the problem, please show me the solutions too.

The following error message:

ImportError: DLL load failed: %1 is not a valid Win32 application.

says your interpreter (which I suspect is embed into PyCharm) is trying to import a 32-bit module. That's simply because interpreter itself is 32-bit. Which means PyCharm is using 32-bit of Python.

Consider using 64-bit of PyCharm or downgrade your PyQt5 to 32-bit.

Disclaimer: I haven't use PyCharm.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM