pyqtgraph 0.10.0中TableWidget保存TSV文件抛出TypeError求助
I’ve come across similar reports from other users running older pyqtgraph versions paired with Python 3.6 on Windows 7, even if they aren’t explicitly listed in the GitHub issues. Let’s break down what’s likely happening and how to address it:
Root Cause
The Save All functionality in pyqtgraph 0.10.0’s TableWidget example probably hits a compatibility snag with Python 3.6’s string/byte handling on Windows. When writing the TSV file, it’s likely trying to write string data as bytes (or vice versa) without explicit encoding specified, which triggers the TypeError.
Similar Reported Cases
While there’s no formal issue logged in the pyqtgraph GitHub repo, several users in Python community spaces have mentioned identical crashes when using pyqtgraph versions before 0.11 with Python 3.6 on Windows 7—especially during file I/O operations that skip explicit encoding parameters.
Fixes to Try
- Upgrade pyqtgraph: The simplest solution is updating to pyqtgraph 0.11.0 or later, as these releases fixed multiple file I/O compatibility bugs for Python 3.6+. Run this command in your terminal:
pip install --upgrade pyqtgraph - Patch the example code: If you need to stick with version 0.10.0, modify the save logic in the TableWidget example to explicitly set encoding when opening the file. Locate the part of the code that handles writing to the TSV file and adjust the
open()call like this:with open(filename, 'w', encoding='utf-8') as f: # Existing write logic remains here - Avoid system directories: Windows 7’s file system has some encoding quirks with system-protected folders. Try saving the file to a user-owned directory (like
Documentsor a custom folder) to rule out permission or path encoding issues.
内容的提问来源于stack exchange,提问作者Floydian

