Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 04-25-2023, 11:06 AM   #1
rb431
Enthusiast
rb431 began at the beginning.
 
Posts: 32
Karma: 10
Join Date: Aug 2020
Device: Kindle Oasis 9th gen
PermissionError: [WinError 5] Access is denied when updating Metadata

I have been dealing with and or troubleshooting this for months and months. I have been using Calibre for many years now, but sometime in 2022 this issue started for me. I generally install the latest release of Calibre a few days after it is announced and I am currently running 6.16.

Here is an example error (this is just one of the three books for this author):

calibre, version 6.16.0
ERROR: Some failures: Failed to apply updated metadata for some books in your library. Click "Show details" to see details.

The Fugitive Pair - Henry Vogel

Traceback (most recent call last):
File "calibre\utils\copy_files.py", line 212, in copy_tree
File "shutil.py", line 739, in rmtree
File "shutil.py", line 621, in _rmtree_unsafe
File "shutil.py", line 619, in _rmtree_unsafe
PermissionError: [WinError 5] Access is denied: 'C:\\Users\\Richard\\Documents\\Calibre Library\\Henry Vogel\\The Fugitive Pair_ Matt & Michelle (3952)'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "calibre\gui2\actions\edit_metadata.py", line 899, in apply_mi
File "calibre\db\legacy.py", line 588, in set_metadata
File "calibre\db\cache.py", line 77, in call_func_with_lock
File "calibre\db\cache.py", line 1685, in set_metadata
File "calibre\db\cache.py", line 1506, in update_path
File "calibre\db\backend.py", line 1887, in update_path
File "calibre\utils\copy_files.py", line 216, in copy_tree
File "shutil.py", line 739, in rmtree
File "shutil.py", line 621, in _rmtree_unsafe
File "shutil.py", line 619, in _rmtree_unsafe
PermissionError: [WinError 5] Access is denied: 'C:\\Users\\Richard\\Documents\\Calibre Library\\Henry Vogel\\The Fugitive Pair_ Matt & Michelle (3952)'

After this error, my library directory looks like this:
Directory of C:\Users\Richard\Documents\Calibre Library\Henry Vogel

04/25/2023 10:27 AM <DIR> .
04/25/2023 10:27 AM <DIR> ..
04/25/2023 10:27 AM <DIR> The Fugitive Heir (3951)
04/25/2023 10:27 AM <DIR> The Fugitive Heir_ Matt & Michelle (3951)
04/25/2023 10:26 AM <DIR> The Fugitive Pair (3952)
04/25/2023 10:26 AM <DIR> The Fugitive Pair_ Matt & Michelle (3952)
04/25/2023 10:27 AM <DIR> The Fugitive Snare (3953)
04/25/2023 10:27 AM <DIR> The Fugitive Snare_ Matt & Michelle (3953)

Three new directories were created and the files moved to them, but then it appears that when python tries to remove the old directories it fails.

I have confirmed absolutely that my directories are NOT read only and my user account running calibre has full access.

This sort of error can happen in two ways. If I am editing the meta data interactively one book at a time and using the download metadata feature, I sometimes get the error. However, if I just clear the error dialog and try to apply the changes again it works.

If I am bulk updating metadata for several books and download the metadata, when I finish reviewing and tweaking the downloaded metadata it errors out trying to save it.

This seems to be happening whenever python is being asked to move the book files between directories. If there is no directory involvement, no errors.

I previously had Google Drive syncing data to Google from the calibre library, but I have stopped that and have quite Drive but still get these errors.

If I run Library checks and have it fix/delete things, there's never an error.

My workaround has been to always edit books individually so I can retry without losing my changes.
rb431 is offline   Reply With Quote
Old 04-25-2023, 11:11 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,194
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Exclude the calibre library folder from your antivirus
kovidgoyal is offline   Reply With Quote
Advert
Old 04-25-2023, 01:26 PM   #3
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 44,828
Karma: 168802811
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
You may also want to move your calibre library outside your Documents folder since Microsoft has been doing security changes in the default permissions on Documents and with their synchronizing to One Drive.

Close calibre, move the library folder in C:\Users\<username>, re-open calibre and under Library dropdown menu, select the Switch/create library, browse to your new library location and make sure that the radio button for Use the previously existing library at the new location is selected.
DNSB is offline   Reply With Quote
Old 04-25-2023, 03:34 PM   #4
Quoth
Still reading
Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.
 
Quoth's Avatar
 
Posts: 13,702
Karma: 103837201
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper
I've always stored all my directly created documents outside "My Documents" since about 1997 when I discovered that logging into a Domain Controller could overwrite those.
Quoth is offline   Reply With Quote
Old 04-25-2023, 03:57 PM   #5
rb431
Enthusiast
rb431 began at the beginning.
 
Posts: 32
Karma: 10
Join Date: Aug 2020
Device: Kindle Oasis 9th gen
I tried both suggestions. First I moved the library to the root of my profile folder to get it outside Documents. Same problem.

Then, since I have McAfee, I turned off real-time scanning altogether since you can't exclude whole folders in McAfee.

Same result:
calibre, version 6.16.0
ERROR: Some failures: Failed to apply updated metadata for some books in your library. Click "Show details" to see details.

The Fugitive Pair - Henry Vogel

Traceback (most recent call last):
File "calibre\utils\copy_files.py", line 212, in copy_tree
File "shutil.py", line 739, in rmtree
File "shutil.py", line 621, in _rmtree_unsafe
File "shutil.py", line 619, in _rmtree_unsafe
PermissionError: [WinError 5] Access is denied: 'C:\\Users\\Richard\\Calibre Library\\Henry Vogel\\The Fugitive Pair_ Matt & Michelle (3952)'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "calibre\gui2\actions\edit_metadata.py", line 899, in apply_mi
File "calibre\db\legacy.py", line 588, in set_metadata
File "calibre\db\cache.py", line 77, in call_func_with_lock
File "calibre\db\cache.py", line 1685, in set_metadata
File "calibre\db\cache.py", line 1506, in update_path
File "calibre\db\backend.py", line 1887, in update_path
File "calibre\utils\copy_files.py", line 216, in copy_tree
File "shutil.py", line 739, in rmtree
File "shutil.py", line 621, in _rmtree_unsafe
File "shutil.py", line 619, in _rmtree_unsafe
PermissionError: [WinError 5] Access is denied: 'C:\\Users\\Richard\\Calibre Library\\Henry Vogel\\The Fugitive Pair_ Matt & Michelle (3952)'

************************************************** ******************************

The Fugitive Snare - Henry Vogel

Traceback (most recent call last):
File "calibre\utils\copy_files.py", line 212, in copy_tree
File "shutil.py", line 739, in rmtree
File "shutil.py", line 621, in _rmtree_unsafe
File "shutil.py", line 619, in _rmtree_unsafe
PermissionError: [WinError 5] Access is denied: 'C:\\Users\\Richard\\Calibre Library\\Henry Vogel\\The Fugitive Snare_ Matt & Michelle (3953)'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "calibre\gui2\actions\edit_metadata.py", line 899, in apply_mi
File "calibre\db\legacy.py", line 588, in set_metadata
File "calibre\db\cache.py", line 77, in call_func_with_lock
File "calibre\db\cache.py", line 1685, in set_metadata
File "calibre\db\cache.py", line 1506, in update_path
File "calibre\db\backend.py", line 1887, in update_path
File "calibre\utils\copy_files.py", line 216, in copy_tree
File "shutil.py", line 739, in rmtree
File "shutil.py", line 621, in _rmtree_unsafe
File "shutil.py", line 619, in _rmtree_unsafe
PermissionError: [WinError 5] Access is denied: 'C:\\Users\\Richard\\Calibre Library\\Henry Vogel\\The Fugitive Snare_ Matt & Michelle (3953)'

************************************************** ******************************

The Fugitive Heir - Henry Vogel

Traceback (most recent call last):
File "calibre\utils\copy_files.py", line 212, in copy_tree
File "shutil.py", line 739, in rmtree
File "shutil.py", line 621, in _rmtree_unsafe
File "shutil.py", line 619, in _rmtree_unsafe
PermissionError: [WinError 5] Access is denied: 'C:\\Users\\Richard\\Calibre Library\\Henry Vogel\\The Fugitive Heir_ Matt & Michelle (3951)'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "calibre\gui2\actions\edit_metadata.py", line 899, in apply_mi
File "calibre\db\legacy.py", line 588, in set_metadata
File "calibre\db\cache.py", line 77, in call_func_with_lock
File "calibre\db\cache.py", line 1685, in set_metadata
File "calibre\db\cache.py", line 1506, in update_path
File "calibre\db\backend.py", line 1887, in update_path
File "calibre\utils\copy_files.py", line 216, in copy_tree
File "shutil.py", line 739, in rmtree
File "shutil.py", line 621, in _rmtree_unsafe
File "shutil.py", line 619, in _rmtree_unsafe
PermissionError: [WinError 5] Access is denied: 'C:\\Users\\Richard\\Calibre Library\\Henry Vogel\\The Fugitive Heir_ Matt & Michelle (3951)'

************************************************** ******************************
rb431 is offline   Reply With Quote
Advert
Old 04-25-2023, 10:43 PM   #6
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,194
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Well the only way you can get permission denied errors is if the permissions are wrong on the files/folders or some program has a file in the folder being deleted open.
kovidgoyal is offline   Reply With Quote
Old 04-27-2023, 09:07 PM   #7
richard6154
Junior Member
richard6154 can extract oil from cheeserichard6154 can extract oil from cheeserichard6154 can extract oil from cheeserichard6154 can extract oil from cheeserichard6154 can extract oil from cheeserichard6154 can extract oil from cheeserichard6154 can extract oil from cheeserichard6154 can extract oil from cheese
 
richard6154's Avatar
 
Posts: 7
Karma: 1000
Join Date: Jul 2022
Location: Perth Australia
Device: Kobo Libra H2O
I fixed this problem for my self by creating a new library folder [using admin acc] on a different drive and coping all my books to the new library. I then set this as my default. Whatever was causing the problem didnt copy across.
richard6154 is offline   Reply With Quote
Old 04-28-2023, 02:04 PM   #8
rb431
Enthusiast
rb431 began at the beginning.
 
Posts: 32
Karma: 10
Join Date: Aug 2020
Device: Kindle Oasis 9th gen
I already had a mirror of my Calibre library on a different disk since I use robocopy to periodically mirror it to another drive plus a USB stick for a backup.

I pointed Calibre at the library on the other disk and got the same errors doing the metadata updates:

calibre, version 6.17.0
ERROR: Some failures: Failed to apply updated metadata for some books in your library. Click "Show details" to see details.

The Fugitive Pair - Henry Vogel

Traceback (most recent call last):
File "calibre\utils\copy_files.py", line 212, in copy_tree
File "shutil.py", line 739, in rmtree
File "shutil.py", line 621, in _rmtree_unsafe
File "shutil.py", line 619, in _rmtree_unsafe
PermissionError: [WinError 5] Access is denied: 'D:\\Calibre Library\\Henry Vogel\\The Fugitive Pair_ Matt & Michelle (3952)'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "calibre\gui2\actions\edit_metadata.py", line 903, in apply_mi
File "calibre\db\legacy.py", line 588, in set_metadata
File "calibre\db\cache.py", line 85, in call_func_with_lock
File "calibre\db\cache.py", line 1704, in set_metadata
File "calibre\db\cache.py", line 1522, in update_path
File "calibre\db\backend.py", line 1875, in update_path
File "calibre\utils\copy_files.py", line 216, in copy_tree
File "shutil.py", line 739, in rmtree
File "shutil.py", line 621, in _rmtree_unsafe
File "shutil.py", line 619, in _rmtree_unsafe
PermissionError: [WinError 5] Access is denied: 'D:\\Calibre Library\\Henry Vogel\\The Fugitive Pair_ Matt & Michelle (3952)'

************************************************** ******************************

The Fugitive Snare - Henry Vogel

Traceback (most recent call last):
File "calibre\utils\copy_files.py", line 212, in copy_tree
File "shutil.py", line 739, in rmtree
File "shutil.py", line 621, in _rmtree_unsafe
File "shutil.py", line 619, in _rmtree_unsafe
PermissionError: [WinError 5] Access is denied: 'D:\\Calibre Library\\Henry Vogel\\The Fugitive Snare_ Matt & Michelle (3953)'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "calibre\gui2\actions\edit_metadata.py", line 903, in apply_mi
File "calibre\db\legacy.py", line 588, in set_metadata
File "calibre\db\cache.py", line 85, in call_func_with_lock
File "calibre\db\cache.py", line 1704, in set_metadata
File "calibre\db\cache.py", line 1522, in update_path
File "calibre\db\backend.py", line 1875, in update_path
File "calibre\utils\copy_files.py", line 216, in copy_tree
File "shutil.py", line 739, in rmtree
File "shutil.py", line 621, in _rmtree_unsafe
File "shutil.py", line 619, in _rmtree_unsafe
PermissionError: [WinError 5] Access is denied: 'D:\\Calibre Library\\Henry Vogel\\The Fugitive Snare_ Matt & Michelle (3953)'

************************************************** ******************************

The Fugitive Heir - Henry Vogel

Traceback (most recent call last):
File "calibre\utils\copy_files.py", line 212, in copy_tree
File "shutil.py", line 739, in rmtree
File "shutil.py", line 621, in _rmtree_unsafe
File "shutil.py", line 619, in _rmtree_unsafe
PermissionError: [WinError 5] Access is denied: 'D:\\Calibre Library\\Henry Vogel\\The Fugitive Heir_ Matt & Michelle (3951)'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "calibre\gui2\actions\edit_metadata.py", line 903, in apply_mi
File "calibre\db\legacy.py", line 588, in set_metadata
File "calibre\db\cache.py", line 85, in call_func_with_lock
File "calibre\db\cache.py", line 1704, in set_metadata
File "calibre\db\cache.py", line 1522, in update_path
File "calibre\db\backend.py", line 1875, in update_path
File "calibre\utils\copy_files.py", line 216, in copy_tree
File "shutil.py", line 739, in rmtree
File "shutil.py", line 621, in _rmtree_unsafe
File "shutil.py", line 619, in _rmtree_unsafe
PermissionError: [WinError 5] Access is denied: 'D:\\Calibre Library\\Henry Vogel\\The Fugitive Heir_ Matt & Michelle (3951)'

************************************************** ******************************

The Authenticated Users group has all permissions but Full Control to that sub-directory and lower.

During the metadata update, Calibre is moving the books to a new folder and it is failing on removing the old folder, which is now empty. I was able to use my account to browse into that directory and remove the folders manually in explorer, so the perms have to be sufficient since I am invoking Python in the same account. My real-time virus scanning is fully disabled.
rb431 is offline   Reply With Quote
Old 04-28-2023, 02:19 PM   #9
rb431
Enthusiast
rb431 began at the beginning.
 
Posts: 32
Karma: 10
Join Date: Aug 2020
Device: Kindle Oasis 9th gen
Could the ampersand in the path name be causing the python function to fail?
rb431 is offline   Reply With Quote
Old 04-28-2023, 02:28 PM   #10
rb431
Enthusiast
rb431 began at the beginning.
 
Posts: 32
Karma: 10
Join Date: Aug 2020
Device: Kindle Oasis 9th gen
As an experiment, is it possible for me to manually rename the directories those books are in and then edit the Library to point to the new location without having to re-import them?
rb431 is offline   Reply With Quote
Old 04-28-2023, 02:29 PM   #11
rb431
Enthusiast
rb431 began at the beginning.
 
Posts: 32
Karma: 10
Join Date: Aug 2020
Device: Kindle Oasis 9th gen
Quote:
Originally Posted by rb431 View Post
As an experiment, is it possible for me to manually rename the directories those books are in and then edit the Library to point to the new location without having to re-import them?
nvm, I figured that bit out. Testing this now.
rb431 is offline   Reply With Quote
Old 04-28-2023, 02:31 PM   #12
rb431
Enthusiast
rb431 began at the beginning.
 
Posts: 32
Karma: 10
Join Date: Aug 2020
Device: Kindle Oasis 9th gen
Quote:
Originally Posted by rb431 View Post
nvm, I figured that bit out. Testing this now.
correction, I figured out how to display the path but I can't seem to edit it manually as I expected to.
rb431 is offline   Reply With Quote
Old 04-28-2023, 02:53 PM   #13
rb431
Enthusiast
rb431 began at the beginning.
 
Posts: 32
Karma: 10
Join Date: Aug 2020
Device: Kindle Oasis 9th gen
Alrighty. More information. I discovered that I could not even delete the books from the library with the & in the path when I had all three highlighted at once.

So I quit Calibre and manually deleted the folders. I then started up Calibre, did a library check, and found no references to those books.

I then imported one of the books using my existing settings which read the metadata from the file itself rather than the filename. That imported it with the & in the path.

That one book I was then able to just DEL and remove from the library.

I changed my import routine to use the filename for metadata and imported all three.

I was then able to download both metadata and covers, review the metadata, and it saved successfully.

I suspect that python is choking on the & possibly in the make_long_path_useable function. A quick search shows people having problems with that combination.
rb431 is offline   Reply With Quote
Old 04-28-2023, 02:59 PM   #14
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 30,905
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
DO NOT ever change a file/folder inside the Library (folder).
That exact path is stored in the DB. Only calibre should rename (Author and title) as it adjusts the DB as part of the task. (if you have don any of this, you need to stop, fix the errors (there are tips on how to isolate good from bad)

Calibre adjust names in some cases to maintain valid path lengths. Yours look fine'

Placing the Library closer to the drive root, can help (Use Calibre to MOVE the Library)
theducks is offline   Reply With Quote
Old 04-28-2023, 03:08 PM   #15
rb431
Enthusiast
rb431 began at the beginning.
 
Posts: 32
Karma: 10
Join Date: Aug 2020
Device: Kindle Oasis 9th gen
Quote:
Originally Posted by theducks View Post
DO NOT ever change a file/folder inside the Library (folder).
That exact path is stored in the DB. Only calibre should rename (Author and title) as it adjusts the DB as part of the task. (if you have don any of this, you need to stop, fix the errors (there are tips on how to isolate good from bad)

Calibre adjust names in some cases to maintain valid path lengths. Yours look fine'

Placing the Library closer to the drive root, can help (Use Calibre to MOVE the Library)
I'm at "D:\Calibre Library" already.
rb431 is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows error 5: Access is denied dschnit1 Calibre 13 05-03-2023 09:45 AM
Calibre: Access Denied Celsus_ Devices 4 07-25-2018 04:54 PM
Windows error 5: Access is denied boh_1 Calibre 3 11-30-2017 10:03 PM
Access denied on serversocket.accept Ricky23289 Kindle Developer's Corner 6 07-11-2014 12:02 PM


All times are GMT -4. The time now is 08:13 AM.


MobileRead.com is a privately owned, operated and funded community.