簡體   English   中英

為什么在使用Python 3.4.3和PyCharm的PyQt5中會出現ImportError?

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

我想使用Python 3.4.3在PyCharm中使用PyQt5庫。 我已經安裝了所有程序,但是PyCharm不能完全運行,但會出現錯誤:

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

我的代碼就是這樣,我將模型從PyQt5導入PyCharm以創建一個簡單的窗口:

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()

僅當我使用PyCharm時才會顯示此錯誤,而不是在Portable Python中顯示。 那么有人可以告訴我如何使用Python 3.4.3和PyQt5設置PyCharm嗎? 如果那不是問題,請也向我展示解決方案。

出現以下錯誤信息:

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

說您的解釋器(我懷疑它已嵌入PyCharm中)正在嘗試導入32位模塊。 這僅僅是因為解釋器本身是32位的。 這意味着PyCharm正在使用32位Python。

考慮使用64位的PyCharm或將PyQt5降級為32位。

免責聲明:我沒有使用PyCharm。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM