Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialhamsternation
26,616 PointsOSError when using send2trash library.
Originally, send2trash raises PermissionError:
>>> send2trash('Testing')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/hamsternation/anaconda3/lib/python3.6/site-packages/send2trash/plat_other.py", line 185, in send2trash
dest_trash = find_ext_volume_trash(topdir)
File "/home/hamsternation/anaconda3/lib/python3.6/site-packages/send2trash/plat_other.py", line 145, in find_ext_volume_trash
trash_dir = find_ext_volume_fallback_trash(volume_root)
File "/home/hamsternation/anaconda3/lib/python3.6/site-packages/send2trash/plat_other.py", line 139, in find_ext_volume_fallback_trash
check_create(trash_dir)
File "/home/hamsternation/anaconda3/lib/python3.6/site-packages/send2trash/plat_other.py", line 84, in check_create
os.makedirs(dir, 0o700)
File "/home/hamsternation/anaconda3/lib/python3.6/os.py", line 220, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: b'/mnt/hgfs/.Trash-1000'
So I exit and run Python in superuser and now it raises OSError:
>>> from send2trash import send2trash
>>> import os
>>> os.listdir()
['.git', '.idea', 'Py Programs', 'Python Projects', 'Testing']
>>> send2trash('Testing')
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/send2trash/plat_gio.py", line 12, in send2trash
f.trash(cancellable=None)
GLib.Error: g-io-error-quark: Unable to find or create trash directory (15)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/send2trash/plat_gio.py", line 14, in send2trash
raise OSError(e.message)
OSError: Unable to find or create trash directory
I am running ubuntu 16.04LTS and using PyCharm terminal, I also tried it in the OS terminal and got the same errors.