[{"data":1,"prerenderedAt":1237},["ShallowReactive",2],{"doc-\u002Ferrors\u002Fpermissionerror-errno-13-permission-denied-fix":3},{"id":4,"title":5,"body":6,"description":1230,"extension":1231,"meta":1232,"navigation":94,"path":1233,"seo":1234,"stem":1235,"__hash__":1236},"content\u002Ferrors\u002Fpermissionerror-errno-13-permission-denied-fix.md","PermissionError: [Errno 13] Permission denied (Fix)",{"type":7,"value":8,"toc":1208},"minimark",[9,19,27,30,46,49,54,57,187,190,201,217,221,224,244,247,250,254,257,274,277,300,304,307,391,394,424,430,506,517,520,524,527,550,553,632,635,652,656,659,664,692,695,699,754,761,765,894,900,904,934,937,941,1074,1077,1081,1084,1098,1105,1121,1125,1129,1132,1136,1145,1149,1152,1156,1159,1163,1204],[10,11,13,14,18],"h1",{"id":12},"permissionerror-errno-13-permission-denied-fix","PermissionError: ",[15,16,17],"span",{},"Errno 13"," Permission denied (Fix)",[20,21,22,26],"p",{},[23,24,25],"code",{},"PermissionError: [Errno 13] Permission denied"," means Python asked the operating system to access a file, folder, or other resource, but the operating system refused.",[20,28,29],{},"This usually happens when:",[31,32,33,37,40,43],"ul",{},[34,35,36],"li",{},"your program does not have permission to read or write something",[34,38,39],{},"the path points to a folder instead of a file",[34,41,42],{},"you are trying to save in a protected location",[34,44,45],{},"another program is locking the file",[20,47,48],{},"The good news is that this error is often easy to fix once you check the path, file type, and location.",[50,51,53],"h2",{"id":52},"quick-fix","Quick fix",[20,55,56],{},"Start with a simple file path that you know you can access:",[58,59,64],"pre",{"className":60,"code":61,"language":62,"meta":63,"style":63},"language-python shiki shiki-themes material-theme-lighter github-light github-dark","file_path = \"example.txt\"\n\nwith open(file_path, \"r\", encoding=\"utf-8\") as file:\n    content = file.read()\n    print(content)\n","python","",[23,65,66,89,96,154,173],{"__ignoreMap":63},[15,67,70,74,78,82,86],{"class":68,"line":69},"line",1,[15,71,73],{"class":72},"su5hD","file_path ",[15,75,77],{"class":76},"smGrS","=",[15,79,81],{"class":80},"sjJ54"," \"",[15,83,85],{"class":84},"s_sjI","example.txt",[15,87,88],{"class":80},"\"\n",[15,90,92],{"class":68,"line":91},2,[15,93,95],{"emptyLinePlaceholder":94},true,"\n",[15,97,99,103,107,111,115,118,120,123,126,128,132,134,136,139,141,144,147,151],{"class":68,"line":98},3,[15,100,102],{"class":101},"sVHd0","with",[15,104,106],{"class":105},"sptTA"," open",[15,108,110],{"class":109},"sP7_E","(",[15,112,114],{"class":113},"slqww","file_path",[15,116,117],{"class":109},",",[15,119,81],{"class":80},[15,121,122],{"class":84},"r",[15,124,125],{"class":80},"\"",[15,127,117],{"class":109},[15,129,131],{"class":130},"s99_P"," encoding",[15,133,77],{"class":76},[15,135,125],{"class":80},[15,137,138],{"class":84},"utf-8",[15,140,125],{"class":80},[15,142,143],{"class":109},")",[15,145,146],{"class":101}," as",[15,148,150],{"class":149},"sMMDD"," file",[15,152,153],{"class":109},":\n",[15,155,157,160,162,164,167,170],{"class":68,"line":156},4,[15,158,159],{"class":72},"    content ",[15,161,77],{"class":76},[15,163,150],{"class":149},[15,165,166],{"class":109},".",[15,168,169],{"class":113},"read",[15,171,172],{"class":109},"()\n",[15,174,176,179,181,184],{"class":68,"line":175},5,[15,177,178],{"class":105},"    print",[15,180,110],{"class":109},[15,182,183],{"class":113},"content",[15,185,186],{"class":109},")\n",[20,188,189],{},"First check that:",[31,191,192,195,198],{},[34,193,194],{},"the path is correct",[34,196,197],{},"the path points to a file, not a folder",[34,199,200],{},"your user account has permission to read or write that location",[20,202,203,204,209,210,166],{},"If needed, review ",[205,206,208],"a",{"href":207},"\u002Flearn\u002Fworking-with-file-paths-in-python","how file paths work in Python"," and the ",[205,211,213,216],{"href":212},"\u002Freference\u002Fpython-open-function-explained",[23,214,215],{},"open()"," function explained",[50,218,220],{"id":219},"what-this-error-means","What this error means",[20,222,223],{},"This error means Python tried to do something like:",[31,225,226,229,232,235,238,241],{},[34,227,228],{},"open a file",[34,230,231],{},"create a file",[34,233,234],{},"modify a file",[34,236,237],{},"delete a file",[34,239,240],{},"rename a file",[34,242,243],{},"access a folder",[20,245,246],{},"But the operating system blocked the action.",[20,248,249],{},"In beginner code, this is usually related to file or folder permissions. It can also happen if you try to write to a protected system location, such as a system folder or a file owned by another user.",[50,251,253],{"id":252},"common-situations-that-cause-it","Common situations that cause it",[20,255,256],{},"Here are the most common reasons:",[31,258,259,262,265,268,271],{},[34,260,261],{},"Trying to write to a file or folder you do not own",[34,263,264],{},"Trying to save a file in a protected system directory",[34,266,267],{},"Using a folder path where Python expects a file path",[34,269,270],{},"Trying to open a file that is locked by another program",[34,272,273],{},"Trying to access a file with the wrong mode, such as writing where only reading is allowed",[20,275,276],{},"Common causes at a glance:",[31,278,279,282,285,288,291,294],{},[34,280,281],{},"Wrong file path points to a folder instead of a file",[34,283,284],{},"No permission to read the file",[34,286,287],{},"No permission to write to the target folder",[34,289,290],{},"File is open or locked by another program",[34,292,293],{},"Trying to modify a protected system file",[34,295,296,297,299],{},"Using ",[23,298,215],{}," on a directory path",[50,301,303],{"id":302},"example-that-causes-the-error","Example that causes the error",[20,305,306],{},"Opening a protected file with write mode can fail:",[58,308,310],{"className":60,"code":309,"language":62,"meta":63,"style":63},"path = \"\u002Fprotected-folder\u002Fexample.txt\"\n\nwith open(path, \"w\", encoding=\"utf-8\") as file:\n    file.write(\"Hello\")\n",[23,311,312,326,330,370],{"__ignoreMap":63},[15,313,314,317,319,321,324],{"class":68,"line":69},[15,315,316],{"class":72},"path ",[15,318,77],{"class":76},[15,320,81],{"class":80},[15,322,323],{"class":84},"\u002Fprotected-folder\u002Fexample.txt",[15,325,88],{"class":80},[15,327,328],{"class":68,"line":91},[15,329,95],{"emptyLinePlaceholder":94},[15,331,332,334,336,338,341,343,345,348,350,352,354,356,358,360,362,364,366,368],{"class":68,"line":98},[15,333,102],{"class":101},[15,335,106],{"class":105},[15,337,110],{"class":109},[15,339,340],{"class":113},"path",[15,342,117],{"class":109},[15,344,81],{"class":80},[15,346,347],{"class":84},"w",[15,349,125],{"class":80},[15,351,117],{"class":109},[15,353,131],{"class":130},[15,355,77],{"class":76},[15,357,125],{"class":80},[15,359,138],{"class":84},[15,361,125],{"class":80},[15,363,143],{"class":109},[15,365,146],{"class":101},[15,367,150],{"class":149},[15,369,153],{"class":109},[15,371,372,375,377,380,382,384,387,389],{"class":68,"line":156},[15,373,374],{"class":149},"    file",[15,376,166],{"class":109},[15,378,379],{"class":113},"write",[15,381,110],{"class":109},[15,383,125],{"class":80},[15,385,386],{"class":84},"Hello",[15,388,125],{"class":80},[15,390,186],{"class":109},[20,392,393],{},"If your account cannot write to that folder, Python may raise:",[58,395,397],{"className":60,"code":396,"language":62,"meta":63,"style":63},"PermissionError: [Errno 13] Permission denied\n",[23,398,399],{"__ignoreMap":63},[15,400,401,405,408,411,414,418,421],{"class":68,"line":69},[15,402,404],{"class":403},"sZMiF","PermissionError",[15,406,407],{"class":109},":",[15,409,410],{"class":109}," [",[15,412,413],{"class":72},"Errno ",[15,415,417],{"class":416},"srdBf","13",[15,419,420],{"class":109},"]",[15,422,423],{"class":72}," Permission denied\n",[20,425,426,427,429],{},"Another common mistake is passing a directory to ",[23,428,215],{}," instead of a file:",[58,431,433],{"className":60,"code":432,"language":62,"meta":63,"style":63},"path = \"my_folder\"\n\nwith open(path, \"r\", encoding=\"utf-8\") as file:\n    print(file.read())\n",[23,434,435,448,452,490],{"__ignoreMap":63},[15,436,437,439,441,443,446],{"class":68,"line":69},[15,438,316],{"class":72},[15,440,77],{"class":76},[15,442,81],{"class":80},[15,444,445],{"class":84},"my_folder",[15,447,88],{"class":80},[15,449,450],{"class":68,"line":91},[15,451,95],{"emptyLinePlaceholder":94},[15,453,454,456,458,460,462,464,466,468,470,472,474,476,478,480,482,484,486,488],{"class":68,"line":98},[15,455,102],{"class":101},[15,457,106],{"class":105},[15,459,110],{"class":109},[15,461,340],{"class":113},[15,463,117],{"class":109},[15,465,81],{"class":80},[15,467,122],{"class":84},[15,469,125],{"class":80},[15,471,117],{"class":109},[15,473,131],{"class":130},[15,475,77],{"class":76},[15,477,125],{"class":80},[15,479,138],{"class":84},[15,481,125],{"class":80},[15,483,143],{"class":109},[15,485,146],{"class":101},[15,487,150],{"class":149},[15,489,153],{"class":109},[15,491,492,494,496,499,501,503],{"class":68,"line":156},[15,493,178],{"class":105},[15,495,110],{"class":109},[15,497,498],{"class":149},"file",[15,500,166],{"class":109},[15,502,169],{"class":113},[15,504,505],{"class":109},"())\n",[20,507,508,509,166],{},"On some systems, this can raise a permission-related error. On others, you may get a different error such as ",[205,510,512,513,516],{"href":511},"\u002Ferrors\u002Fisadirectoryerror-errno-21-is-a-directory-fix","IsADirectoryError: ",[15,514,515],{},"Errno 21"," Is a directory",[20,518,519],{},"Deleting or renaming files in restricted locations can also cause the same problem.",[50,521,523],{"id":522},"how-to-fix-it","How to fix it",[20,525,526],{},"Work through these checks one by one:",[31,528,529,532,535,538,541,544,547],{},[34,530,531],{},"Check that the path points to a real file, not a directory",[34,533,534],{},"Make sure the file or folder exists in a location you can access",[34,536,537],{},"Use a different folder such as your home directory, Desktop, or project folder",[34,539,540],{},"Close other programs that may be using the file",[34,542,543],{},"Check whether you need read mode or write mode",[34,545,546],{},"Run the script with the correct user account",[34,548,549],{},"Only use admin or sudo access when truly necessary",[20,551,552],{},"A safer beginner approach is to work inside your project folder:",[58,554,556],{"className":60,"code":555,"language":62,"meta":63,"style":63},"path = \"notes.txt\"\n\nwith open(path, \"w\", encoding=\"utf-8\") as file:\n    file.write(\"This file is in my project folder.\")\n",[23,557,558,571,575,613],{"__ignoreMap":63},[15,559,560,562,564,566,569],{"class":68,"line":69},[15,561,316],{"class":72},[15,563,77],{"class":76},[15,565,81],{"class":80},[15,567,568],{"class":84},"notes.txt",[15,570,88],{"class":80},[15,572,573],{"class":68,"line":91},[15,574,95],{"emptyLinePlaceholder":94},[15,576,577,579,581,583,585,587,589,591,593,595,597,599,601,603,605,607,609,611],{"class":68,"line":98},[15,578,102],{"class":101},[15,580,106],{"class":105},[15,582,110],{"class":109},[15,584,340],{"class":113},[15,586,117],{"class":109},[15,588,81],{"class":80},[15,590,347],{"class":84},[15,592,125],{"class":80},[15,594,117],{"class":109},[15,596,131],{"class":130},[15,598,77],{"class":76},[15,600,125],{"class":80},[15,602,138],{"class":84},[15,604,125],{"class":80},[15,606,143],{"class":109},[15,608,146],{"class":101},[15,610,150],{"class":149},[15,612,153],{"class":109},[15,614,615,617,619,621,623,625,628,630],{"class":68,"line":156},[15,616,374],{"class":149},[15,618,166],{"class":109},[15,620,379],{"class":113},[15,622,110],{"class":109},[15,624,125],{"class":80},[15,626,627],{"class":84},"This file is in my project folder.",[15,629,125],{"class":80},[15,631,186],{"class":109},[20,633,634],{},"This usually works because you normally have permission to create and edit files in your own working folder.",[20,636,637,638,642,643,651],{},"If the file might not exist, also check ",[205,639,641],{"href":640},"\u002Fhow-to\u002Fhow-to-check-if-a-file-exists-in-python","how to test whether a file exists in Python",". If the path is wrong, you may see ",[205,644,646,647,650],{"href":645},"\u002Ferrors\u002Ffilenotfounderror-errno-2-no-such-file-or-directory-fix","FileNotFoundError: ",[15,648,649],{},"Errno 2"," No such file or directory"," instead.",[50,653,655],{"id":654},"how-to-debug-step-by-step","How to debug step by step",[20,657,658],{},"When you are not sure what is wrong, print and test the path directly.",[660,661,663],"h3",{"id":662},"_1-print-the-exact-path","1. Print the exact path",[58,665,667],{"className":60,"code":666,"language":62,"meta":63,"style":63},"path = \"example.txt\"\nprint(path)\n",[23,668,669,681],{"__ignoreMap":63},[15,670,671,673,675,677,679],{"class":68,"line":69},[15,672,316],{"class":72},[15,674,77],{"class":76},[15,676,81],{"class":80},[15,678,85],{"class":84},[15,680,88],{"class":80},[15,682,683,686,688,690],{"class":68,"line":91},[15,684,685],{"class":105},"print",[15,687,110],{"class":109},[15,689,340],{"class":113},[15,691,186],{"class":109},[20,693,694],{},"This helps you confirm the program is using the path you expect.",[660,696,698],{"id":697},"_2-check-whether-the-path-exists","2. Check whether the path exists",[58,700,702],{"className":60,"code":701,"language":62,"meta":63,"style":63},"import os\n\npath = \"example.txt\"\nprint(os.path.exists(path))\n",[23,703,704,712,716,728],{"__ignoreMap":63},[15,705,706,709],{"class":68,"line":69},[15,707,708],{"class":101},"import",[15,710,711],{"class":72}," os\n",[15,713,714],{"class":68,"line":91},[15,715,95],{"emptyLinePlaceholder":94},[15,717,718,720,722,724,726],{"class":68,"line":98},[15,719,316],{"class":72},[15,721,77],{"class":76},[15,723,81],{"class":80},[15,725,85],{"class":84},[15,727,88],{"class":80},[15,729,730,732,734,737,739,742,744,747,749,751],{"class":68,"line":156},[15,731,685],{"class":105},[15,733,110],{"class":109},[15,735,736],{"class":113},"os",[15,738,166],{"class":109},[15,740,340],{"class":741},"skxfh",[15,743,166],{"class":109},[15,745,746],{"class":113},"exists",[15,748,110],{"class":109},[15,750,340],{"class":113},[15,752,753],{"class":109},"))\n",[20,755,756,757,760],{},"If this prints ",[23,758,759],{},"False",", the path is wrong or the file does not exist.",[660,762,764],{"id":763},"_3-check-whether-it-is-a-file-or-a-directory","3. Check whether it is a file or a directory",[58,766,768],{"className":60,"code":767,"language":62,"meta":63,"style":63},"import os\n\npath = \"example.txt\"\n\nprint(\"Exists:\", os.path.exists(path))\nprint(\"Is file:\", os.path.isfile(path))\nprint(\"Is directory:\", os.path.isdir(path))\n",[23,769,770,776,780,792,796,828,861],{"__ignoreMap":63},[15,771,772,774],{"class":68,"line":69},[15,773,708],{"class":101},[15,775,711],{"class":72},[15,777,778],{"class":68,"line":91},[15,779,95],{"emptyLinePlaceholder":94},[15,781,782,784,786,788,790],{"class":68,"line":98},[15,783,316],{"class":72},[15,785,77],{"class":76},[15,787,81],{"class":80},[15,789,85],{"class":84},[15,791,88],{"class":80},[15,793,794],{"class":68,"line":156},[15,795,95],{"emptyLinePlaceholder":94},[15,797,798,800,802,804,807,809,811,814,816,818,820,822,824,826],{"class":68,"line":175},[15,799,685],{"class":105},[15,801,110],{"class":109},[15,803,125],{"class":80},[15,805,806],{"class":84},"Exists:",[15,808,125],{"class":80},[15,810,117],{"class":109},[15,812,813],{"class":113}," os",[15,815,166],{"class":109},[15,817,340],{"class":741},[15,819,166],{"class":109},[15,821,746],{"class":113},[15,823,110],{"class":109},[15,825,340],{"class":113},[15,827,753],{"class":109},[15,829,831,833,835,837,840,842,844,846,848,850,852,855,857,859],{"class":68,"line":830},6,[15,832,685],{"class":105},[15,834,110],{"class":109},[15,836,125],{"class":80},[15,838,839],{"class":84},"Is file:",[15,841,125],{"class":80},[15,843,117],{"class":109},[15,845,813],{"class":113},[15,847,166],{"class":109},[15,849,340],{"class":741},[15,851,166],{"class":109},[15,853,854],{"class":113},"isfile",[15,856,110],{"class":109},[15,858,340],{"class":113},[15,860,753],{"class":109},[15,862,864,866,868,870,873,875,877,879,881,883,885,888,890,892],{"class":68,"line":863},7,[15,865,685],{"class":105},[15,867,110],{"class":109},[15,869,125],{"class":80},[15,871,872],{"class":84},"Is directory:",[15,874,125],{"class":80},[15,876,117],{"class":109},[15,878,813],{"class":113},[15,880,166],{"class":109},[15,882,340],{"class":741},[15,884,166],{"class":109},[15,886,887],{"class":113},"isdir",[15,889,110],{"class":109},[15,891,340],{"class":113},[15,893,753],{"class":109},[20,895,896,897,899],{},"This is important because ",[23,898,215],{}," expects a file path, not a directory path.",[660,901,903],{"id":902},"_4-check-your-current-working-folder","4. Check your current working folder",[58,905,907],{"className":60,"code":906,"language":62,"meta":63,"style":63},"import os\n\nprint(os.getcwd())\n",[23,908,909,915,919],{"__ignoreMap":63},[15,910,911,913],{"class":68,"line":69},[15,912,708],{"class":101},[15,914,711],{"class":72},[15,916,917],{"class":68,"line":91},[15,918,95],{"emptyLinePlaceholder":94},[15,920,921,923,925,927,929,932],{"class":68,"line":98},[15,922,685],{"class":105},[15,924,110],{"class":109},[15,926,736],{"class":113},[15,928,166],{"class":109},[15,930,931],{"class":113},"getcwd",[15,933,505],{"class":109},[20,935,936],{},"Sometimes the relative path is fine, but your script is running from a different folder than you expected.",[660,938,940],{"id":939},"_5-try-a-simple-read-test","5. Try a simple read test",[58,942,944],{"className":60,"code":943,"language":62,"meta":63,"style":63},"path = \"example.txt\"\n\ntry:\n    with open(path, \"r\", encoding=\"utf-8\") as f:\n        print(f.read())\nexcept Exception as e:\n    print(type(e).__name__)\n    print(e)\n",[23,945,946,958,962,969,1009,1025,1040,1063],{"__ignoreMap":63},[15,947,948,950,952,954,956],{"class":68,"line":69},[15,949,316],{"class":72},[15,951,77],{"class":76},[15,953,81],{"class":80},[15,955,85],{"class":84},[15,957,88],{"class":80},[15,959,960],{"class":68,"line":91},[15,961,95],{"emptyLinePlaceholder":94},[15,963,964,967],{"class":68,"line":98},[15,965,966],{"class":101},"try",[15,968,153],{"class":109},[15,970,971,974,976,978,980,982,984,986,988,990,992,994,996,998,1000,1002,1004,1007],{"class":68,"line":156},[15,972,973],{"class":101},"    with",[15,975,106],{"class":105},[15,977,110],{"class":109},[15,979,340],{"class":113},[15,981,117],{"class":109},[15,983,81],{"class":80},[15,985,122],{"class":84},[15,987,125],{"class":80},[15,989,117],{"class":109},[15,991,131],{"class":130},[15,993,77],{"class":76},[15,995,125],{"class":80},[15,997,138],{"class":84},[15,999,125],{"class":80},[15,1001,143],{"class":109},[15,1003,146],{"class":101},[15,1005,1006],{"class":72}," f",[15,1008,153],{"class":109},[15,1010,1011,1014,1016,1019,1021,1023],{"class":68,"line":175},[15,1012,1013],{"class":105},"        print",[15,1015,110],{"class":109},[15,1017,1018],{"class":113},"f",[15,1020,166],{"class":109},[15,1022,169],{"class":113},[15,1024,505],{"class":109},[15,1026,1027,1030,1033,1035,1038],{"class":68,"line":830},[15,1028,1029],{"class":101},"except",[15,1031,1032],{"class":403}," Exception",[15,1034,146],{"class":101},[15,1036,1037],{"class":72}," e",[15,1039,153],{"class":109},[15,1041,1042,1044,1046,1049,1051,1054,1057,1061],{"class":68,"line":863},[15,1043,178],{"class":105},[15,1045,110],{"class":109},[15,1047,1048],{"class":403},"type",[15,1050,110],{"class":109},[15,1052,1053],{"class":113},"e",[15,1055,1056],{"class":109},").",[15,1058,1060],{"class":1059},"s_hVV","__name__",[15,1062,186],{"class":109},[15,1064,1066,1068,1070,1072],{"class":68,"line":1065},8,[15,1067,178],{"class":105},[15,1069,110],{"class":109},[15,1071,1053],{"class":113},[15,1073,186],{"class":109},[20,1075,1076],{},"This shows the full error clearly and helps you confirm whether the problem is the path, the file type, or permissions.",[50,1078,1080],{"id":1079},"safe-beginner-advice","Safe beginner advice",[20,1082,1083],{},"If you are new to Python, these habits will help you avoid permission problems:",[31,1085,1086,1089,1092,1095],{},[34,1087,1088],{},"Prefer working inside your own project folder",[34,1090,1091],{},"Avoid protected locations until you understand permissions better",[34,1093,1094],{},"Do not solve every permission problem by running as administrator",[34,1096,1097],{},"If the path comes from user input, validate it before using it",[20,1099,1100,1101,1104],{},"Running as administrator or with ",[23,1102,1103],{},"sudo"," can sometimes make the error go away, but it is not the best first fix. It is safer to use files and folders that your account already controls.",[20,1106,1107,1108,1116,1117,166],{},"If you are dealing with different path problems, you may also want to read ",[205,1109,1111,1112,1115],{"href":1110},"\u002Ferrors\u002Fnotadirectoryerror-errno-20-not-a-directory-fix","NotADirectoryError: ",[15,1113,1114],{},"Errno 20"," Not a directory"," or the broader guide to ",[205,1118,1120],{"href":1119},"\u002Ferrors\u002Foserror-in-python-causes-and-fixes","OSError in Python: causes and fixes",[50,1122,1124],{"id":1123},"faq","FAQ",[660,1126,1128],{"id":1127},"why-do-i-get-permissionerror-even-when-the-file-exists","Why do I get PermissionError even when the file exists?",[20,1130,1131],{},"Because existence and permission are different. The file may be there, but your program may not be allowed to read or change it.",[660,1133,1135],{"id":1134},"can-a-folder-path-cause-this-error","Can a folder path cause this error?",[20,1137,1138,1139,1141,1142,1144],{},"Yes. If you pass a directory to ",[23,1140,215],{},", Python may fail because ",[23,1143,215],{}," expects a file path.",[660,1146,1148],{"id":1147},"should-i-always-run-python-as-administrator-to-fix-this","Should I always run Python as administrator to fix this?",[20,1150,1151],{},"No. It is better to use a file location you already have access to. Admin access should be a last resort.",[660,1153,1155],{"id":1154},"can-another-program-cause-permissionerror","Can another program cause PermissionError?",[20,1157,1158],{},"Yes. A file can be locked by another app, which can stop Python from reading, writing, renaming, or deleting it.",[50,1160,1162],{"id":1161},"see-also","See also",[31,1164,1165,1170,1175,1182,1188,1194,1200],{},[34,1166,1167],{},[205,1168,1169],{"href":640},"How to check if a file exists in Python",[34,1171,1172],{},[205,1173,1174],{"href":207},"Working with file paths in Python",[34,1176,1177],{},[205,1178,1179,1180,216],{"href":212},"Python ",[23,1181,215],{},[34,1183,1184],{},[205,1185,646,1186,650],{"href":645},[15,1187,649],{},[34,1189,1190],{},[205,1191,512,1192,516],{"href":511},[15,1193,515],{},[34,1195,1196],{},[205,1197,1111,1198,1115],{"href":1110},[15,1199,1114],{},[34,1201,1202],{},[205,1203,1120],{"href":1119},[1205,1206,1207],"style",{},"html pre.shiki code .su5hD, html code.shiki .su5hD{--shiki-light:#90A4AE;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .smGrS, html code.shiki .smGrS{--shiki-light:#39ADB5;--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sjJ54, html code.shiki .sjJ54{--shiki-light:#39ADB5;--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .s_sjI, html code.shiki .s_sjI{--shiki-light:#91B859;--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sVHd0, html code.shiki .sVHd0{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#D73A49;--shiki-default-font-style:inherit;--shiki-dark:#F97583;--shiki-dark-font-style:inherit}html pre.shiki code .sptTA, html code.shiki .sptTA{--shiki-light:#6182B8;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sP7_E, html code.shiki .sP7_E{--shiki-light:#39ADB5;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .slqww, html code.shiki .slqww{--shiki-light:#6182B8;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .s99_P, html code.shiki .s99_P{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#E36209;--shiki-default-font-style:inherit;--shiki-dark:#FFAB70;--shiki-dark-font-style:inherit}html pre.shiki code .sMMDD, html code.shiki .sMMDD{--shiki-light:#90A4AE;--shiki-default:#E36209;--shiki-dark:#FFAB70}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sZMiF, html code.shiki .sZMiF{--shiki-light:#E2931D;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .srdBf, html code.shiki .srdBf{--shiki-light:#F76D47;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .skxfh, html code.shiki .skxfh{--shiki-light:#E53935;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .s_hVV, html code.shiki .s_hVV{--shiki-light:#90A4AE;--shiki-default:#005CC5;--shiki-dark:#79B8FF}",{"title":63,"searchDepth":91,"depth":91,"links":1209},[1210,1211,1212,1213,1214,1215,1222,1223,1229],{"id":52,"depth":91,"text":53},{"id":219,"depth":91,"text":220},{"id":252,"depth":91,"text":253},{"id":302,"depth":91,"text":303},{"id":522,"depth":91,"text":523},{"id":654,"depth":91,"text":655,"children":1216},[1217,1218,1219,1220,1221],{"id":662,"depth":98,"text":663},{"id":697,"depth":98,"text":698},{"id":763,"depth":98,"text":764},{"id":902,"depth":98,"text":903},{"id":939,"depth":98,"text":940},{"id":1079,"depth":91,"text":1080},{"id":1123,"depth":91,"text":1124,"children":1224},[1225,1226,1227,1228],{"id":1127,"depth":98,"text":1128},{"id":1134,"depth":98,"text":1135},{"id":1147,"depth":98,"text":1148},{"id":1154,"depth":98,"text":1155},{"id":1161,"depth":91,"text":1162},"Master permissionerror errno 13 permission denied fix in our comprehensive Python beginner guide.","md",{},"\u002Ferrors\u002Fpermissionerror-errno-13-permission-denied-fix",{"title":5,"description":1230},"errors\u002Fpermissionerror-errno-13-permission-denied-fix","lsX7kIDbXw2Kh8bY1qyKy3EQRaMRGjb3eNRTDYpnZhc",1777585498500]