PySide2 seems corectly Installed but fails to load
-
@Silenzio76 How did you install PySide2?
Also, do you call Python interpreter for which you installed PySide2?
Do you have more than one Python installed? -
Okay as a side note consider this Python 2.7 was deprecated back in 2015 (it is now 2019) and we are on Python 3.7 so how long do you think it will be before they deprecate (stop supporting) earlier versions of Python yes I know PySide2 has not fully caught up yet but then why use PySide2 when a fully caught up version exists pyqt5. Unless you are specifically working on the PySide2 project or need it for some obscure reason moving to pyqt5 should be simple since PySide2 and pyqt5 are both based on QT5 and as such are not all that different. So I would (unless you have some extremely solid reasons for not doing so) strongly suggest upgrading to the latest versions of both Python 3.7 and pyqt5 --- then these issues of things not syncing up solidly would be a non-issue.
Note: Part of this is a question to you in the form of why use PySide2 over pyqt5 what are the benefits or needs to do so?
-
@Denni In the meanwhile thanks to put light on my eyes.
I was misguided on use PySide2 because I need to produce macro for a free-software and in it's tutorial is shown to use PySide(not PySide2).
Mine it's only ignorance!
However, I recive the same error when I switched on pyqt5.
the software is named lexocad...
error.. from PyQt5.QtWidgets import QApplication, ... -
@Silenzio76 Can you show the exact error?
-
@Silenzio76 Is it possible that lexocad brings its own Python interpreter? If this is the case installing PyQt in your Python setup will not solve the problem.
-
Okay my first question would be can you access Python and the PyQt libraries from the command line run and import the library. The python Path might not be in your system variables and/or PyQt might not be accessible to python.
Better yet try and run this program from a command line my typing "Python TestProgram.py" and copy the following into a text document and name it "TestProgram.py"
If you cannot run this then the issue is with your install if you can run this the issue is with Lexocad
import sys from PyQt5.QtCore import * from PyQt5.QtGui import * from PyQt5.QtWidgets import * class CustomItemModel(QStandardItemModel): def headerData(self, section, orientation, role): if role == Qt.ForegroundRole: brush = QBrush() brush.setColor(Qt.blue) brush.setStyle(Qt.SolidPattern) return brush elif role == Qt.BackgroundRole: brush = QBrush() brush.setColor(Qt.yellow) brush.setStyle(Qt.SolidPattern) return brush elif role == Qt.FontRole: font = QFont() font.setBold(True) font.setPointSize(10) return font return super().headerData(section, orientation, role) class ItemDsplyr(QTreeView): def __init__(self): QTreeView.__init__(self) self.model = CustomItemModel(0, 3) self.model.setHorizontalHeaderLabels(['Column1', 'Column2', 'Column3']) self.setModel(self.model) self.clicked.connect(self.itemSingleClicked) def itemSingleClicked(self, index): Item = self.selectedIndexes()[0] ItemVal = Item.model().itemFromIndex(index).text() print("Item Clicked:",ItemVal) def SetContent(self): self.model.setRowCount(0) ItmRecSet = [ {'CatgryName':'Cat-1', 'GroupName':'Run-Grp-1', 'ItemName':'Run-Itm-1'}, {'CatgryName':'Cat-1', 'GroupName':'Run-Grp-1', 'ItemName':'Run-Itm-2'}, {'CatgryName':'Cat-1', 'GroupName':'Run-Grp-1', 'ItemName':'Run-Itm-3'} ] for Item in ItmRecSet: ItmNam = QStandardItem(Item['ItemName']) CatNam = QStandardItem(Item['CatgryName']) GrpNam = QStandardItem(Item['GroupName']) self.model.appendRow([CatNam, GrpNam, ItmNam]) class CenterPane(QWidget): def __init__(self, parent): QWidget.__init__(self) self.MainWin = parent self.ItemDsply = ItemDsplyr() self.ItemDsply.SetContent() CntrPane = QSplitter(Qt.Horizontal, self) CntrPane.addWidget(QTextEdit()) CntrPane.addWidget(self.ItemDsply) CntrPane.setSizes([75,200]) hbox = QHBoxLayout(self) hbox.addWidget(CntrPane) self.setLayout(hbox) @property def MainWin(self): return self.__parent @MainWin.setter def MainWin(self, value): self.__parent = value class Window(QMainWindow): def __init__(self, parent=None): super(Window, self).__init__(parent) self.setCentralWidget(CenterPane(self)) if __name__ == "__main__": qApp = QApplication([]) qApp.setStyle("fusion") GUI = Window() GUI.show() sys.exit(qApp.exec_())