{"id":2092,"date":"2020-06-24T23:17:43","date_gmt":"2020-06-24T14:17:43","guid":{"rendered":"https:\/\/itips.krsw.biz\/?p=2092"},"modified":"2020-06-24T23:17:43","modified_gmt":"2020-06-24T14:17:43","slug":"python-filenotfounderror","status":"publish","type":"post","link":"https:\/\/itips.krsw.biz\/en\/python-filenotfounderror\/","title":{"rendered":"[Python] FileNotFoundError reason and solution"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/itips.krsw.biz\/wp-content\/uploads\/2018\/12\/code_1545140786-1024x683.jpg\" alt=\"[Python] FileNotFoundError reason and solution\" width=\"800\" height=\"534\" class=\"aligncenter size-large wp-image-139\" srcset=\"https:\/\/itips.krsw.biz\/wp-content\/uploads\/2018\/12\/code_1545140786-1024x683.jpg 1024w, https:\/\/itips.krsw.biz\/wp-content\/uploads\/2018\/12\/code_1545140786-640x427.jpg 640w, https:\/\/itips.krsw.biz\/wp-content\/uploads\/2018\/12\/code_1545140786-800x534.jpg 800w, https:\/\/itips.krsw.biz\/wp-content\/uploads\/2018\/12\/code_1545140786-320x214.jpg 320w, https:\/\/itips.krsw.biz\/wp-content\/uploads\/2018\/12\/code_1545140786-768x512.jpg 768w, https:\/\/itips.krsw.biz\/wp-content\/uploads\/2018\/12\/code_1545140786-400x267.jpg 400w, https:\/\/itips.krsw.biz\/wp-content\/uploads\/2018\/12\/code_1545140786-300x200.jpg 300w, https:\/\/itips.krsw.biz\/wp-content\/uploads\/2018\/12\/code_1545140786.jpg 1280w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>When Python code reads file, it may cause <code>FileNotFoundError<\/code>.<br \/>\nThe reason of the error is &quot;File is not found&quot;.<br \/>\nIf it reads single file, it can be OK to prepare the missing file.<br \/>\nBut in case of multiple files, you would like to continue the process.<\/p>\n<p>In this article, I introduce the reason and solution about <code>FileNotFoundError<\/code>.<\/p>\n<div class=\"st-mybox  has-title st-mybox-class\" style=\"background:#fafafa;border-width:0px;border-radius:5px;margin: 25px 0 25px 0;\"><p class=\"st-mybox-title\" style=\"color:#757575;font-weight:bold;text-shadow: #fff 3px 0px 0px, #fff 2.83487px 0.981584px 0px, #fff 2.35766px 1.85511px 0px, #fff 1.62091px 2.52441px 0px, #fff 0.705713px 2.91581px 0px, #fff -0.287171px 2.98622px 0px, #fff -1.24844px 2.72789px 0px, #fff -2.07227px 2.16926px 0px, #fff -2.66798px 1.37182px 0px, #fff -2.96998px 0.42336px 0px, #fff -2.94502px -0.571704px 0px, #fff -2.59586px -1.50383px 0px, #fff -1.96093px -2.27041px 0px, #fff -1.11013px -2.78704px 0px, #fff -0.137119px -2.99686px 0px, #fff 0.850987px -2.87677px 0px, #fff 1.74541px -2.43999px 0px, #fff 2.44769px -1.73459px 0px, #fff 2.88051px -0.838246px 0px;\"><i class=\"fa fa-file-text-o st-css-no\" aria-hidden=\"true\"><\/i>Reference<\/p><div class=\"st-in-mybox\">\n<li><a href=\"https:\/\/docs.python.org\/3\/library\/exceptions.html\">Built-in Exceptions \u2014 Python 3.8.3 documentation<\/a><\/li>\n<\/div><\/div>\n<p><!--more--><\/p>\n<p><\/br><\/p>\n<h2>Cause of FileNotFoundError<\/h2>\n<p><img decoding=\"async\" src=\"https:\/\/itips.krsw.biz\/wp-content\/uploads\/2020\/04\/why_1586096503-800x450.jpg\" alt=\"\" \/><\/p>\n<p>The cause of <code>FileNotFoundError<\/code> is &quot;File is not found&quot;.<br \/>\nIt means that <span class=\"st-mymarker-s\">it tried to access particular files but the files does not exist.<\/span><\/p>\n<p>In the example below, it tries to read from <code>0.csv<\/code> to <code>2.csv<\/code>. But <code>1.csv<\/code> does not exist. So it causes <code>FileNotFoundError<\/code>.<\/p>\n<pre class=\"prettyprint\">\nfile_not_found_v0.py\ncsv\n\u25140.csv\n\u25142.csv\n<\/pre>\n<pre class=\"prettyprint lang-python\">\nimport pandas as pd\n\nfor i in range(3):\n    filename = &#34;csv&#47;{}.csv&#34;.format(str(i))\n    print(filename)\n    df = pd.read_csv(filename)\n    print(df)\n    print()\n\n# csv&#47;0.csv\n#   column\n# 0  value\n# 1  value\n# 2  value\n\n# csv&#47;1.csv\n# FileNotFoundError: &#091;Errno 2&#093; File b&#39;csv&#47;1.csv&#39; does not exist: b&#39;csv&#47;1.csv&#39;\n<\/pre>\n<p><\/br><\/p>\n<h2>How to avoid FileNotFoundError<\/h2>\n<p><img decoding=\"async\" src=\"https:\/\/itips.krsw.biz\/wp-content\/uploads\/2020\/04\/solution_1585920095-800x420.jpg\" alt=\"\" \/><\/p>\n<p>Like the previous example, sometimes there is a lack of files.<\/p>\n<p>Sometimes you would like to stop the process.<br \/>\n<span class=\"st-mymarker-s\">Sometimes you want to run the code with existing files.<\/span><\/p>\n<p>In order to avoid <code>FileNotFoundError<\/code>, there are 2 ways.<\/p>\n<div class=\"st-mybox  has-title \" style=\"background:#FFFDE7;border-color:#FFD54F;border-width:2px;border-radius:5px;margin: 25px 0;\"><p class=\"st-mybox-title\" style=\"color:#FFD54F;font-weight:bold;text-shadow: #fff 3px 0px 0px, #fff 2.83487px 0.981584px 0px, #fff 2.35766px 1.85511px 0px, #fff 1.62091px 2.52441px 0px, #fff 0.705713px 2.91581px 0px, #fff -0.287171px 2.98622px 0px, #fff -1.24844px 2.72789px 0px, #fff -2.07227px 2.16926px 0px, #fff -2.66798px 1.37182px 0px, #fff -2.96998px 0.42336px 0px, #fff -2.94502px -0.571704px 0px, #fff -2.59586px -1.50383px 0px, #fff -1.96093px -2.27041px 0px, #fff -1.11013px -2.78704px 0px, #fff -0.137119px -2.99686px 0px, #fff 0.850987px -2.87677px 0px, #fff 1.74541px -2.43999px 0px, #fff 2.44769px -1.73459px 0px, #fff 2.88051px -0.838246px 0px;\"><i class=\"fa fa-check-circle st-css-no\" aria-hidden=\"true\"><\/i>Avoiding FileNotFoundError<\/p><div class=\"st-in-mybox\">\n<li>Check existence<\/li>\n<li>Skip the error<\/li>\n<\/div><\/div>\n<p><\/br><\/p>\n<h3>Check existence<\/h3>\n<p>The <code>FileNotFoundError<\/code> happens when we try to access non-existent file.<br \/>\n<span class=\"st-mymarker-s\">So we can avoid it by checking existence.<\/span><\/p>\n<p>In order o check existence, we can use <code>os.path.exists()<\/code>.<br \/>\nYou can set file path as a parameter.<\/p>\n<pre class=\"prettyprint lang-python\">\nimport pandas as pd\nimport os\n\nfor i in range(3):\n    filename = &#34;csv&#47;{}.csv&#34;.format(str(i))\n    print(filename)\n\n    if os.path.exists(filename):\n        df = pd.read_csv(filename)\n        print(df)\n    else:\n        print(&#34;{} not found.&#34;.format(filename))\n    print()\n\n# csv&#47;0.csv\n#   column\n# 0  value\n# 1  value\n# 2  value\n#\n# csv&#47;1.csv\n# csv&#47;1.csv not found.\n#\n# csv&#47;2.csv\n#   column\n# 0  value\n# 1  value\n# 2  value\n<\/pre>\n<p><\/br><\/p>\n<h3>Skip the error<\/h3>\n<p>Another method is skipping the error.<br \/>\nEven <code>FileNotFoundError<\/code> occurs, run the process.<br \/>\nIn order to do it, use <code>try<\/code> and <code>except<\/code>.<br \/>\nOnce <code>FileNotFoundError<\/code> occurs, go to <code>except<\/code> process andrun the next loop process.<\/p>\n<p>Then you can run the process with existing files.<\/p>\n<pre class=\"prettyprint lang-python\">\nfor i in range(3):\n    filename = &#34;csv&#47;{}.csv&#34;.format(str(i))\n    print(filename)\n\n    try:\n        df = pd.read_csv(filename)\n        print(df)\n    except FileNotFoundError as e:\n        print(&#34;{} not found.&#34;.format(filename))\n    print()\n\n# csv&#47;0.csv\n#   column\n# 0  value\n# 1  value\n# 2  value\n#\n# csv&#47;1.csv\n# csv&#47;1.csv not found.\n#\n# csv&#47;2.csv\n#   column\n# 0  value\n# 1  value\n# 2  value\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>When Python code reads file, it may cause FileNotFoundError. The reason of the error is &quot;File i &#8230; <\/p>\n","protected":false},"author":1,"featured_media":139,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"en_US","_original_post":"https:\/\/itips.krsw.biz\/?p=2087","footnotes":""},"categories":[6],"tags":[131,130],"class_list":["post-2092","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-131","tag-130","en-US"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>[Python] FileNotFoundError reason and solution - ITips\u30b7\u30b9\u30c6\u30e0\u30bd\u30ea\u30e5\u30fc\u30b7\u30e7\u30f3\u30ba<\/title>\n<meta name=\"description\" content=\"When Python code reads file, it may cause `FileNotFoundError`.The reason of the error is &quot;File is not found&quot;.If it reads single file, it can be OK to prepare the missing file.But in case of multiple files, you would like to continue the process.In this article, I introduce the reason and solution about `FileNotFoundError`.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/itips.krsw.biz\/en\/python-filenotfounderror\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Python] FileNotFoundError reason and solution - ITips\u30b7\u30b9\u30c6\u30e0\u30bd\u30ea\u30e5\u30fc\u30b7\u30e7\u30f3\u30ba\" \/>\n<meta property=\"og:description\" content=\"When Python code reads file, it may cause `FileNotFoundError`.The reason of the error is &quot;File is not found&quot;.If it reads single file, it can be OK to prepare the missing file.But in case of multiple files, you would like to continue the process.In this article, I introduce the reason and solution about `FileNotFoundError`.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/itips.krsw.biz\/en\/python-filenotfounderror\/\" \/>\n<meta property=\"og:site_name\" content=\"ITips\u30b7\u30b9\u30c6\u30e0\u30bd\u30ea\u30e5\u30fc\u30b7\u30e7\u30f3\u30ba\" \/>\n<meta property=\"article:published_time\" content=\"2020-06-24T14:17:43+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/itips.krsw.biz\/wp-content\/uploads\/2018\/12\/code_1545140786.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"854\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"ITips\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/karasan_itips\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"ITips\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/itips.krsw.biz\\\/en\\\/python-filenotfounderror\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/itips.krsw.biz\\\/en\\\/python-filenotfounderror\\\/\"},\"author\":{\"name\":\"ITips\",\"@id\":\"https:\\\/\\\/itips.krsw.biz\\\/#\\\/schema\\\/person\\\/981ee81393a64c1b43f0b62d91998f0c\"},\"headline\":\"[Python] FileNotFoundError reason and solution\",\"datePublished\":\"2020-06-24T14:17:43+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/itips.krsw.biz\\\/en\\\/python-filenotfounderror\\\/\"},\"wordCount\":270,\"image\":{\"@id\":\"https:\\\/\\\/itips.krsw.biz\\\/en\\\/python-filenotfounderror\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/itips.krsw.biz\\\/wp-content\\\/uploads\\\/2018\\\/12\\\/code_1545140786.jpg\",\"keywords\":[\"Error\",\"File\"],\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/itips.krsw.biz\\\/en\\\/python-filenotfounderror\\\/\",\"url\":\"https:\\\/\\\/itips.krsw.biz\\\/en\\\/python-filenotfounderror\\\/\",\"name\":\"[Python] FileNotFoundError reason and solution - ITips\u30b7\u30b9\u30c6\u30e0\u30bd\u30ea\u30e5\u30fc\u30b7\u30e7\u30f3\u30ba\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/itips.krsw.biz\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/itips.krsw.biz\\\/en\\\/python-filenotfounderror\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/itips.krsw.biz\\\/en\\\/python-filenotfounderror\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/itips.krsw.biz\\\/wp-content\\\/uploads\\\/2018\\\/12\\\/code_1545140786.jpg\",\"datePublished\":\"2020-06-24T14:17:43+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/itips.krsw.biz\\\/#\\\/schema\\\/person\\\/981ee81393a64c1b43f0b62d91998f0c\"},\"description\":\"When Python code reads file, it may cause `FileNotFoundError`.The reason of the error is \\\"File is not found\\\".If it reads single file, it can be OK to prepare the missing file.But in case of multiple files, you would like to continue the process.In this article, I introduce the reason and solution about `FileNotFoundError`.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/itips.krsw.biz\\\/en\\\/python-filenotfounderror\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/itips.krsw.biz\\\/en\\\/python-filenotfounderror\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/itips.krsw.biz\\\/en\\\/python-filenotfounderror\\\/#primaryimage\",\"url\":\"https:\\\/\\\/itips.krsw.biz\\\/wp-content\\\/uploads\\\/2018\\\/12\\\/code_1545140786.jpg\",\"contentUrl\":\"https:\\\/\\\/itips.krsw.biz\\\/wp-content\\\/uploads\\\/2018\\\/12\\\/code_1545140786.jpg\",\"width\":1280,\"height\":854},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/itips.krsw.biz\\\/en\\\/python-filenotfounderror\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u30db\u30fc\u30e0\",\"item\":\"https:\\\/\\\/itips.krsw.biz\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Python] FileNotFoundError reason and solution\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/itips.krsw.biz\\\/#website\",\"url\":\"https:\\\/\\\/itips.krsw.biz\\\/\",\"name\":\"ITips\u30b7\u30b9\u30c6\u30e0\u30bd\u30ea\u30e5\u30fc\u30b7\u30e7\u30f3\u30ba\",\"description\":\"\u4e8b\u696d\u306b\u3068\u3063\u3066\u91cd\u8981\u306a\u60c5\u5831\u30b7\u30b9\u30c6\u30e0\u306e\u8ab2\u984c\u3092\u89e3\u6c7a\u3057\u307e\u3059\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/itips.krsw.biz\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/itips.krsw.biz\\\/#\\\/schema\\\/person\\\/981ee81393a64c1b43f0b62d91998f0c\",\"name\":\"ITips\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a89ef68c98cf6b05d7754a22b3e650bab179284eafbaa216db990ab3650cd763?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a89ef68c98cf6b05d7754a22b3e650bab179284eafbaa216db990ab3650cd763?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a89ef68c98cf6b05d7754a22b3e650bab179284eafbaa216db990ab3650cd763?s=96&d=mm&r=g\",\"caption\":\"ITips\"},\"description\":\"\u30b7\u30b9\u30c6\u30e0\u30a8\u30f3\u30b8\u30cb\u30a2\u3001AI\u30a8\u30f3\u30b8\u30cb\u30a2\u3068\u3001IT\u696d\u754c\u306710\u5e74\u4ee5\u4e0a\u50cd\u3044\u3066\u3044\u308b\u4e2d\u5805\u3002Python\u3068SQL\u304c\u5f97\u610f\u3002 System engineer AI engineer, Data scientist. Mid-carrier IT person. Good at Python and SQL.\",\"sameAs\":[\"https:\\\/\\\/www.pinterest.jp\\\/it_karasan\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/karasan_itips\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Python] FileNotFoundError reason and solution - ITips\u30b7\u30b9\u30c6\u30e0\u30bd\u30ea\u30e5\u30fc\u30b7\u30e7\u30f3\u30ba","description":"When Python code reads file, it may cause `FileNotFoundError`.The reason of the error is \"File is not found\".If it reads single file, it can be OK to prepare the missing file.But in case of multiple files, you would like to continue the process.In this article, I introduce the reason and solution about `FileNotFoundError`.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/itips.krsw.biz\/en\/python-filenotfounderror\/","og_locale":"en_US","og_type":"article","og_title":"[Python] FileNotFoundError reason and solution - ITips\u30b7\u30b9\u30c6\u30e0\u30bd\u30ea\u30e5\u30fc\u30b7\u30e7\u30f3\u30ba","og_description":"When Python code reads file, it may cause `FileNotFoundError`.The reason of the error is \"File is not found\".If it reads single file, it can be OK to prepare the missing file.But in case of multiple files, you would like to continue the process.In this article, I introduce the reason and solution about `FileNotFoundError`.","og_url":"https:\/\/itips.krsw.biz\/en\/python-filenotfounderror\/","og_site_name":"ITips\u30b7\u30b9\u30c6\u30e0\u30bd\u30ea\u30e5\u30fc\u30b7\u30e7\u30f3\u30ba","article_published_time":"2020-06-24T14:17:43+00:00","og_image":[{"width":1280,"height":854,"url":"https:\/\/itips.krsw.biz\/wp-content\/uploads\/2018\/12\/code_1545140786.jpg","type":"image\/jpeg"}],"author":"ITips","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/karasan_itips","twitter_misc":{"Written by":"ITips","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/itips.krsw.biz\/en\/python-filenotfounderror\/#article","isPartOf":{"@id":"https:\/\/itips.krsw.biz\/en\/python-filenotfounderror\/"},"author":{"name":"ITips","@id":"https:\/\/itips.krsw.biz\/#\/schema\/person\/981ee81393a64c1b43f0b62d91998f0c"},"headline":"[Python] FileNotFoundError reason and solution","datePublished":"2020-06-24T14:17:43+00:00","mainEntityOfPage":{"@id":"https:\/\/itips.krsw.biz\/en\/python-filenotfounderror\/"},"wordCount":270,"image":{"@id":"https:\/\/itips.krsw.biz\/en\/python-filenotfounderror\/#primaryimage"},"thumbnailUrl":"https:\/\/itips.krsw.biz\/wp-content\/uploads\/2018\/12\/code_1545140786.jpg","keywords":["Error","File"],"articleSection":["Python"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/itips.krsw.biz\/en\/python-filenotfounderror\/","url":"https:\/\/itips.krsw.biz\/en\/python-filenotfounderror\/","name":"[Python] FileNotFoundError reason and solution - ITips\u30b7\u30b9\u30c6\u30e0\u30bd\u30ea\u30e5\u30fc\u30b7\u30e7\u30f3\u30ba","isPartOf":{"@id":"https:\/\/itips.krsw.biz\/#website"},"primaryImageOfPage":{"@id":"https:\/\/itips.krsw.biz\/en\/python-filenotfounderror\/#primaryimage"},"image":{"@id":"https:\/\/itips.krsw.biz\/en\/python-filenotfounderror\/#primaryimage"},"thumbnailUrl":"https:\/\/itips.krsw.biz\/wp-content\/uploads\/2018\/12\/code_1545140786.jpg","datePublished":"2020-06-24T14:17:43+00:00","author":{"@id":"https:\/\/itips.krsw.biz\/#\/schema\/person\/981ee81393a64c1b43f0b62d91998f0c"},"description":"When Python code reads file, it may cause `FileNotFoundError`.The reason of the error is \"File is not found\".If it reads single file, it can be OK to prepare the missing file.But in case of multiple files, you would like to continue the process.In this article, I introduce the reason and solution about `FileNotFoundError`.","breadcrumb":{"@id":"https:\/\/itips.krsw.biz\/en\/python-filenotfounderror\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/itips.krsw.biz\/en\/python-filenotfounderror\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/itips.krsw.biz\/en\/python-filenotfounderror\/#primaryimage","url":"https:\/\/itips.krsw.biz\/wp-content\/uploads\/2018\/12\/code_1545140786.jpg","contentUrl":"https:\/\/itips.krsw.biz\/wp-content\/uploads\/2018\/12\/code_1545140786.jpg","width":1280,"height":854},{"@type":"BreadcrumbList","@id":"https:\/\/itips.krsw.biz\/en\/python-filenotfounderror\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u30db\u30fc\u30e0","item":"https:\/\/itips.krsw.biz\/"},{"@type":"ListItem","position":2,"name":"[Python] FileNotFoundError reason and solution"}]},{"@type":"WebSite","@id":"https:\/\/itips.krsw.biz\/#website","url":"https:\/\/itips.krsw.biz\/","name":"ITips\u30b7\u30b9\u30c6\u30e0\u30bd\u30ea\u30e5\u30fc\u30b7\u30e7\u30f3\u30ba","description":"\u4e8b\u696d\u306b\u3068\u3063\u3066\u91cd\u8981\u306a\u60c5\u5831\u30b7\u30b9\u30c6\u30e0\u306e\u8ab2\u984c\u3092\u89e3\u6c7a\u3057\u307e\u3059","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/itips.krsw.biz\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/itips.krsw.biz\/#\/schema\/person\/981ee81393a64c1b43f0b62d91998f0c","name":"ITips","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/a89ef68c98cf6b05d7754a22b3e650bab179284eafbaa216db990ab3650cd763?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/a89ef68c98cf6b05d7754a22b3e650bab179284eafbaa216db990ab3650cd763?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/a89ef68c98cf6b05d7754a22b3e650bab179284eafbaa216db990ab3650cd763?s=96&d=mm&r=g","caption":"ITips"},"description":"\u30b7\u30b9\u30c6\u30e0\u30a8\u30f3\u30b8\u30cb\u30a2\u3001AI\u30a8\u30f3\u30b8\u30cb\u30a2\u3068\u3001IT\u696d\u754c\u306710\u5e74\u4ee5\u4e0a\u50cd\u3044\u3066\u3044\u308b\u4e2d\u5805\u3002Python\u3068SQL\u304c\u5f97\u610f\u3002 System engineer AI engineer, Data scientist. Mid-carrier IT person. Good at Python and SQL.","sameAs":["https:\/\/www.pinterest.jp\/it_karasan\/","https:\/\/x.com\/https:\/\/twitter.com\/karasan_itips"]}]}},"_links":{"self":[{"href":"https:\/\/itips.krsw.biz\/wp-json\/wp\/v2\/posts\/2092","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itips.krsw.biz\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itips.krsw.biz\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itips.krsw.biz\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itips.krsw.biz\/wp-json\/wp\/v2\/comments?post=2092"}],"version-history":[{"count":3,"href":"https:\/\/itips.krsw.biz\/wp-json\/wp\/v2\/posts\/2092\/revisions"}],"predecessor-version":[{"id":2095,"href":"https:\/\/itips.krsw.biz\/wp-json\/wp\/v2\/posts\/2092\/revisions\/2095"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itips.krsw.biz\/wp-json\/wp\/v2\/media\/139"}],"wp:attachment":[{"href":"https:\/\/itips.krsw.biz\/wp-json\/wp\/v2\/media?parent=2092"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itips.krsw.biz\/wp-json\/wp\/v2\/categories?post=2092"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itips.krsw.biz\/wp-json\/wp\/v2\/tags?post=2092"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}