paper-qa icon indicating copy to clipboard operation
paper-qa copied to clipboard

Permission issues when reading pdf

Open qayyumabro opened this issue 2 years ago • 1 comments

Sorry i'm very new with python. It'm trying to read pdf from a directory but it's giving permission issue. Throws same error even when cmd is started as admin.

for pdf_file in pdf_files:
    file_path = os.path.join(pdf_directory, pdf_file)
    print(file_path)
    try:
        with open(file_path, "rb") as f:
            docs.add_file(f, "Joel S. Cohen - Computer Algebra and Symbolic Computation_ Mathematical Methods-AK Peters, Ltd. (2003)")
    except ValueError as e:
        print('Could not read', file_path, e)
Traceback (most recent call last):
  File "C:\Users\USER\Desktop\gpt4all\paper.py", line 40, in <module>
    docs.add_file(f, "Joel S. Cohen - Computer Algebra and Symbolic Computation_ Mathematical Methods-AK Peters, Ltd. (2003)")
  File "C:\Python311\Lib\site-packages\paperqa\docs.py", line 138, in add_file
    return self.add(
           ^^^^^^^^^
  File "C:\Python311\Lib\site-packages\paperqa\docs.py", line 179, in add
    dockey = md5sum(path)
             ^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\paperqa\utils.py", line 73, in md5sum
    with open(file_path, "rb") as f:
         ^^^^^^^^^^^^^^^^^^^^^
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\USER~1\\AppData\\Local\\Temp\\tmpvqq80x3f.pdf'

qayyumabro avatar Aug 16 '23 10:08 qayyumabro

I have also encountered the same problem. Have you resolved it now?

chenghuiling avatar Sep 07 '23 03:09 chenghuiling

Hello @qayyumabro thank you for the issue. It seems unrelated to paper-qa, instead it's specific to Python on your machine, so I am going to close this out.

Perhaps you can find a solution to your issue here: https://stackoverflow.com/q/41910583

jamesbraza avatar Sep 11 '24 17:09 jamesbraza