I have a 'treatment.py' module, which needs 2 files to be input: defects.csv and data.csv. Instead of directly writing the path, I decided to use the QFileDialog dialog from PyQt5. When I select both files, the following error occurs:
Traceback (most recent call last): File "D:/...", line 63, in <module> tr.treat(defects, data) File "D:\Working\ML\Трещины CD\treatment.py", line 16, in treat def90_18 = pd.read_csv(p_def90_18, sep=';', encoding='latin-1') File "C:\Python\lib\site-packages\pandas\io\parsers.py", line 702, in parser_f return _read(filepath_or_buffer, kwds) File "C:\Python\lib\site-packages\pandas\io\parsers.py", line 413, in _read filepath_or_buffer, encoding, compression) File "C:\Python\lib\site-packages\pandas\io\common.py", line 232, in get_filepath_or_buffer raise ValueError(msg.format(_type=type(filepath_or_buffer))) ValueError: Invalid file path or buffer object type: <class '__main__.App1'> I use the following dialog box code:
import sys from PyQt5.QtWidgets import QApplication, QWidget, QFileDialog import treatment as tr class App1(QWidget): def __init__(self): super().__init__() self.left = 500 self.top = 300 self.width = 640 self.height = 480 self.initUI() def initUI(self): self.setGeometry(self.left, self.top, self.width, self.height) self.openFileNameDialog1() self.show() self.close() def openFileNameDialog1(self): global defects options = QFileDialog.Options() options |= QFileDialog.DontUseNativeDialog defects, _ = QFileDialog.getOpenFileName(self,"Выберите файл с \"defects\" ", "", '(*.csv)', options=options) if defects: return defects class App2(QWidget): def __init__(self): super().__init__() self.left = 500 self.top = 300 self.width = 640 self.height = 480 self.initUI() def initUI(self): self.setGeometry(self.left, self.top, self.width, self.height) self.openFileNameDialog2() self.show() self.close() def openFileNameDialog2(self): global data options = QFileDialog.Options() options |= QFileDialog.DontUseNativeDialog data, _ = QFileDialog.getOpenFileName(self, "Выберите файл \"data\" ", "", '(*.csv)', options=options) if data: return data if __name__ == '__main__': app = QApplication(sys.argv) defects = App1() data = App2() tr.treat(defects, data) sys.exit(app.exec_()) What am I doing wrong?

defects = App1().openFileNameDialog2()and it is unclear why you are making such a call inside theglobal defectsmethod? - Alexander Chernin