RP4 端口上的互斥销毁失败
2022 年 3 月 16 日星期三晚上 9:43
你好,我对 Raspberry Pi 比较陌生,一直在尝试将一些最初为 Windows 编译的 Python 源代码移植到 Pi 4。我能够移植除 Win32API 之外的所有内容,我最后注释掉“import win32api”。
python 代码运行到最后一个错误处理语句,我相信它与 win32api 有关。每当我运行此代码时,我都会收到错误“python3:../../libusb/os/threads_posix.h:58: usbi_mutex_destroy: Assertion `pthread_mutex_destroy(mutex) == 0' failed。”
我追踪到的代码是:
if __name__ == '__main__':
# vp_start_gui()
# find_usb_port()
root = tk.Tk()
prog_call = sys.argv[0]
prog_location = os.path.split(prog_call)[0]
define.APP_LOCATION = prog_location
file_location = os.path.join(prog_location, "./project_loc.txt")
# Get project folder path
f = open(file_location, 'r')
file_loc = f.read().replace('\n', '').strip()
f.close()
define.ASSAY_FOLDER_PATH = str(file_loc)
# print("define.ASSAY_FOLDER_PATH11: ", define.ASSAY_FOLDER_PATH)
try:
while define.ASSAY_FOLDER_PATH == "":
define.LOAD_ASSAY_FILE = True
resp = tkinter.messagebox.askokcancel('Select Directory for Assay files: ',
"Select a directory for Assay files and log files")
if resp is True:
define.ASSAY_FOLDER_PATH = filedialog.askdirectory(title='Select a directory for INT05 Project')
else:
root.destroy()
sys.exit()
# Save the log folder file to log_loc.txt to save logs
f = open(file_location, 'w')
f.writelines(str(define.ASSAY_FOLDER_PATH))
f.close()
# debug_print("define.ASSAY_FOLDER_PATH: ", define.ASSAY_FOLDER_PATH)
client = ThreadedClient(root)
root.mainloop()
except Exception as e:
# debug_print(e)
messagebox.showerror("ERROR", "Run the app with administrative privilege... "
"(This has to be done on very first run!")
sys.exit()
运行时,GUI 会弹出“错误”、“使用管理权限运行应用程序...”语句,无论我是否以 root 身份运行代码。
任何有关我做错了什么或如何解决此错误的想法将不胜感激!我已经在这方面投入了一段时间了。
谢谢!
Wed Mar 16, 2022 9:43 pm
Hi, I am relatively new to the Raspberry Pi and have been trying to port some Python source code originally compiled for Windows to a Pi 4. I was able to port everything over save for Win32API, I ended up commenting out "import win32api".
The python code runs until the last error handling statement and I believe it has to do with win32api. Whenever I run this code, I get the error "python3:../../libusb/os/threads_posix.h:58: usbi_mutex_destroy: Assertion `pthread_mutex_destroy(mutex) == 0' failed."
The bit of code that I've traced it to is:
if __name__ == '__main__':
# vp_start_gui()
# find_usb_port()
root = tk.Tk()
prog_call = sys.argv[0]
prog_location = os.path.split(prog_call)[0]
define.APP_LOCATION = prog_location
file_location = os.path.join(prog_location, "./project_loc.txt")
# Get project folder path
f = open(file_location, 'r')
file_loc = f.read().replace('\n', '').strip()
f.close()
define.ASSAY_FOLDER_PATH = str(file_loc)
# print("define.ASSAY_FOLDER_PATH11: ", define.ASSAY_FOLDER_PATH)
try:
while define.ASSAY_FOLDER_PATH == "":
define.LOAD_ASSAY_FILE = True
resp = tkinter.messagebox.askokcancel('Select Directory for Assay files: ',
"Select a directory for Assay files and log files")
if resp is True:
define.ASSAY_FOLDER_PATH = filedialog.askdirectory(title='Select a directory for INT05 Project')
else:
root.destroy()
sys.exit()
# Save the log folder file to log_loc.txt to save logs
f = open(file_location, 'w')
f.writelines(str(define.ASSAY_FOLDER_PATH))
f.close()
# debug_print("define.ASSAY_FOLDER_PATH: ", define.ASSAY_FOLDER_PATH)
client = ThreadedClient(root)
root.mainloop()
except Exception as e:
# debug_print(e)
messagebox.showerror("ERROR", "Run the app with administrative privilege... "
"(This has to be done on very first run!")
sys.exit()
When run, the GUI pops up with the "ERROR", "Run the app with administrative privilege..." statement regardless if I run the code as root.
Any ideas on what I am doing wrong or how to get around this error would be greatly appreciated! I've been spinning my wheels on this for awhile now.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论