簡體   English   中英

從 USB 打開並讀取 txt 文件

[英]Open and read txt file from USB

我正在使用 Linux。我知道我的 USB 名稱是:

Bus 001 Device 005: ID 8564:1000 Transcend Information, Inc. JetFlash

idVendor 和 idProduct 是:

idVendor           0x8564 Transcend Information, Inc.   
idProduct          0x1000 JetFlash

問題出在哪兒? 缺少代碼或其他東西?

我閱讀了PyUSB:從 USB 設備讀取 (2)和其他場景,但與我的並不完全相同,所以請幫忙。

import usb.core
import usb.util

dev = usb.core.find(idVendor= 0x8564, idProduct=0x1000)

ep = dev[0].interfaces()[0].endpoints()[0]
i=dev[0].interfaces()[0].bInterfaceNumber
dev.reset()

if dev.is_kernel_driver_active(i):
    print("hello")

來自 linux 命令的 output(usb.core.USBError:[Errno 13] 訪問被拒絕):

linux 命令的輸出(usb.core.USBError: [Errno 13] Access denied )

  • 嘗試使用“sudo python The_one_i_want.py”

嘗試使用 sudo python The_one_i_want.py

output 是

sudo: python:找不到指令
須藤:python:找不到命令

我剛剛檢查了我的 sudo 是否正常工作:
須藤正在工作

我試過后的 output, sudo python The_one_i_want.py現在顯示 output

python: 無法打開文件 '/home/joy/fe_dir/The_one_i_want.py': [Errno 2] 沒有那個文件或目錄無法打開文件

但是文件The_one_I_want (new).py The_one_I_want.py位於/fe_dir目錄中

更新嘗試:現在是'ModuleNotFoundError:沒有名為'usb'的模塊,如何從這里解決?
ModuleNotFoundError:沒有名為“usb”的模塊

只需使用sudo運行

sudo python The_one_i_want.py

因為您得到的錯誤表明您無權這樣做。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM