Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用错误的参数类型调用PySide2.QtWidgets.QXXLayout.addWidget_Python_Python 3.x_Pyinstaller_Pyside2 - Fatal编程技术网

Python 使用错误的参数类型调用PySide2.QtWidgets.QXXLayout.addWidget

Python 使用错误的参数类型调用PySide2.QtWidgets.QXXLayout.addWidget,python,python-3.x,pyinstaller,pyside2,Python,Python 3.x,Pyinstaller,Pyside2,我正在尝试使用addWidget函数和TypeError将FigureCanvasQTAgg参数作为小部件添加到某些布局中。仅当尝试运行使用pyinstaller构建的独立应用程序时,才会出现此错误。当直接运行脚本时,一切正常 我使用的是python=3.6,PySide2=5.12.3,pyInstaller=3.4 从PySide2.qtwidts导入QApplication、QMainWindow、QMessageBox、QLineEdit、QComboBox、QWidget 导入matp

我正在尝试使用addWidget函数和TypeError将FigureCanvasQTAgg参数作为小部件添加到某些布局中。仅当尝试运行使用pyinstaller构建的独立应用程序时,才会出现此错误。当直接运行脚本时,一切正常

我使用的是
python=3.6
PySide2=5.12.3
pyInstaller=3.4

从PySide2.qtwidts导入QApplication、QMainWindow、QMessageBox、QLineEdit、QComboBox、QWidget
导入matplotlib
matplotlib.use(“Qt5Agg”)
从PySide2.QtCore导入Qt
从matplotlib.backends.backend_qt5agg导入FigureCanvas qtagg as FigureCanvas
从matplotlib.backends.backend_qt5agg导入导航工具栏2qt作为导航工具栏
从matplotlib.figure导入图形
类任务ConfigCreatorAdapter(QMainWindow):
定义初始化(自):
super(TasksConfigCreatorAdapter,self)。\uuuu init\uuuuuu()
self.dialog=Ui\u TasksConfigCreatorDialog()
self.dialog.setupUi(self)
self.figure=无
self.setupCanvasLayout()
def设置画布布局(自):
如果self.figure为无:
self.figure=plt.figure()
self.canvas=FigureCanvas(self.figure)
self.figure.set_facecolor(“白色”)
self.toolbar=导航工具栏(self.canvas,无)
self.dialog.canvasLayout.addWidget(self.canvas,*(0,0))
self.dialog.canvasLayout.addWidget(self.toolbar,*(1,0))

通过将
PyQt5
模块添加到spec文件中的排除列表,解决了此问题。 在尝试以一个文件夹模式创建单机版时,我发现添加了
PyQt5
文件以及
PySide2
文件,这些文件会中断并导致此问题发生。

我也遇到了类似的问题

TypeError: 'qRegisterResourceData' called with wrong argument types:
  qRegisterResourceData(int, str, str, str)
Supported signatures:
  qRegisterResourceData(int, unicode, unicode, unicode)
我的错误是,我使用的是Python3,没有使用
-py3
标志来编译qrc文件,其中默认值是Python2

Usage: C:\Python36\Lib\site-packages\PySide\pyside-rcc.exe  [options] <inputs>

Options:
    -o file           Write output to file rather than stdout
    -py2              Generate code for any Python v2.x version (default)
    -py3              Generate code for any Python v3.x version
    -name name        Create an external initialization function with name
    -threshold level  Threshold to consider compressing files
    -compress level   Compress input files by level
    -root path        Prefix resource access path with root path
    -no-compress      Disable all compression
    -version          Display version
    -help             Display this information
用法:C:\Python36\Lib\site packages\PySide\PySide-rcc.exe[选项]
选项:
-o文件写入输出到文件而不是标准输出
-py2为任何Python v2.x版本生成代码(默认)
-py3为任何Python v3.x版本生成代码
-名称创建一个名为的外部初始化函数
-考虑压缩文件的阈值级阈值
-压缩级别按级别压缩输入文件
-根路径前缀具有根路径的资源访问路径
-无压缩禁用所有压缩
-版本显示版本
-帮助显示此信息

这可能只是一种解决方法,但是您是否尝试过显式地从
addWidget
的第一个重载设置默认值?是的,我尝试过这种解决方法,但没有成功。
Usage: C:\Python36\Lib\site-packages\PySide\pyside-rcc.exe  [options] <inputs>

Options:
    -o file           Write output to file rather than stdout
    -py2              Generate code for any Python v2.x version (default)
    -py3              Generate code for any Python v3.x version
    -name name        Create an external initialization function with name
    -threshold level  Threshold to consider compressing files
    -compress level   Compress input files by level
    -root path        Prefix resource access path with root path
    -no-compress      Disable all compression
    -version          Display version
    -help             Display this information