pythonlinuxfile-transfermtppymtp

Download file from MTP connected device with Python on Ubuntu


I'm trying to download a file from an MTP connected device.

import pymtp

device = pymtp.MTP()

device.connect()

print(device.get_filelisting())

for file in device.get_filelisting():
    if file.item_id == 2000018:
        device.get_file_to_file(file.item_id, "/home/enws/Desktop/")

device.disconnect()

And I get this in the terminal which isn't very helpful to me in finding my error.

Device 0 (VID=04e8 and PID=6860) is a Samsung Galaxy models (MTP).
[b'gara.docx' (2000017)]
Segmentation fault (core dumped)

Has anyone used pymtp on linux with python version 3.6.5 before?

Can anyone help me understand this error?

Or are there alternatives for this? I just want to be able to read files on a connected USB device and download them to local.

My Ubuntu version is 18.04 if it is relevant.


Solution

  • I used mtpy instead, which worked without problems. Although, it doesn't have everything implemented.