Questions tagged [file-not-found]

An error, exit status, or exception that indicates that the file denoted by a specified pathname could not be found.

An error, exit status, or exception that indicates that the file denoted by a specified pathname could not be found. In other words, you're trying to access a file that doesn't exist where the code is expecting it to be.

This could occur as a result of many different actions, such as...

  1. The file doesn't actually exist, or was deleted before you could access it
  2. There is a spelling mistake in your pathname, or the pathname contains characters that aren't permitted in the pathname.
  3. You're using a relative pathname (such as file.txt) and the file doesn't exist in the default working directory for your application
  4. The code is getting confused due to different directory path indicators on different operating systems (ie / vs \)
  5. The programming language interprets the \ character in a String to be a escape character for a special symbol (such as \n indicating new-line), and you're using single \ slashes as directory indicators instead of \\ for a single escaped slash.
  6. In some languages, it could also give this exception if you aren't able to access the file due to security permissions.

Your code should be able to prevent or handle this condition, such as by doing the following...

  1. Detect - Many programming languages allow you to create a File object as a virtual representation of a physical file. Further to this, you can usually call a method or function that asks whether the file exists, such as exists();. This would allow you to check the file exists before you attempt to access it
  2. Prevent - If the user is selecting a file, present them with a FileChooser dialog rather than a text entry field. FileChooser dialogs echo the files that exist in the system, so spelling mistakes are avoided. If you're using relative paths, convert them to absolute paths if practical, or ensure you set the relative path location to a known directory before trying to access files relatively.
  3. Handle - Wrap your file access methods in exception-handling code, such as a try-catch block. This will allow you to catch unexpected exceptions, and perform an alternate operation, such as alerting the user of the error.
601 questions
549
votes
19 answers

Linux error while loading shared libraries: cannot open shared object file: No such file or directory

Program is part of the Xenomai test suite, cross-compiled from Linux PC into Linux+Xenomai ARM toolchain. # echo $LD_LIBRARY_PATH …
zaratustra
  • 8,148
  • 8
  • 36
  • 42
125
votes
10 answers

open() gives FileNotFoundError / IOError: '[Errno 2] No such file or directory'

I am trying to open the file recentlyUpdated.yaml from my Python script. But when I try using: open('recentlyUpdated.yaml') I get an error that says: IOError: [Errno 2] No such file or directory: 'recentlyUpdated.yaml' Why? How can I fix the…
Santiago
  • 1,984
  • 4
  • 19
  • 24
100
votes
2 answers

How do I raise a FileNotFoundError properly?

I use a third-party library that's fine but does not handle inexistant files the way I would like. When giving it a non-existant file, instead of raising the good old FileNotFoundError: [Errno 2] No such file or directory: 'nothing.txt' it raises…
zezollo
  • 4,606
  • 5
  • 28
  • 59
36
votes
10 answers

“File not found”, “linker command failed with exit code 1” in Xcode 4.5.1

Am developing an existing iOS application and I have to write unit test cases for this project. It is building and running in Simulator 6.0. Whenever I try to test the project, it is showing the error message below. Am not able to figure the exact…
Yuvaraj.M
  • 9,741
  • 16
  • 71
  • 100
25
votes
5 answers

C# windows application Event: CLR20r3 on application start

I created a C# application and installed it on my test box. My app works perfect on my dev box, but when I install in on a different machine it crashes in the Main(). I get the EventType: CLR20r3 here is the Event Message Problem signature: …
Tyler
  • 1,134
  • 1
  • 10
  • 12
25
votes
1 answer

FileNotFoundException: "Could not load file or assembly" although assembly exists

I am trying to create a custom membership and role provider. The code for this seems to be fine, but when I try to go to the Security section of the Web Site Administration Tool, I get the following: The invoked member is not supported in a…
25
votes
9 answers

ImportError: The 'enchant' C library was not found. Please install it via your OS package manager, or use a pre-built binary wheel from PyPI

The question is why I see the error message in the title when trying to import enchant. I am using Win64.
1man
  • 5,216
  • 7
  • 42
  • 56
23
votes
4 answers

HTTP Error 404.7 - Not Found The request filtering module is configured to deny the file extension

I'm trying to configure the default webpage for an IIS 7.5 website. Request filtering is turned on. However .aspx pages are allowed, I've set default.aspx to be the default page for the website. If I browse to localhost/default.aspx I get a webpage…
mattbloke
  • 1,028
  • 1
  • 12
  • 26
21
votes
14 answers

pandas.read_csv FileNotFoundError: File b'\xe2\x80\xaa' despite correct path

I'm trying to load a .csv file using the pd.read_csv() function when I get an error despite the file path being correct and using raw strings. import pandas as pd df = pd.read_csv('‪C:\\Users\\user\\Desktop\\datafile.csv') df =…
Impuls3H
  • 303
  • 1
  • 2
  • 11
21
votes
9 answers

Flask "Error: The file/path provided does not appear to exist" although the file does exist

I use export FLASK_APP=flask_app and then do flask run but I get the error: Error: The file/path provided (flask_app) does not appear to exist. Please verify the path is correct. If app is not on PYTHONPATH, ensure the extension is .py However,…
PDiracDelta
  • 2,348
  • 5
  • 21
  • 43
20
votes
2 answers

Python FileNotFound

I am fairly new to python. I am trying to make a script that will read sudoku solutions and determent if they are correct or not. Things I need: 1] Prompt the user to enter a file/file path which includes the sudoku numbers. Its a .txt file of 9…
zilox
  • 209
  • 1
  • 2
  • 4
19
votes
1 answer

aapt not found when building new Android app in NetBeans

I just installed NetBeans and the Android SDK following the instructions here. I am running Ubuntu 9.10 (Karmic). NetBeans is 6.7.1. The Android SDK is version 7. When I try to compile a new project it gives me the following error: Execute failed:…
Oz.
  • 5,299
  • 2
  • 23
  • 30
17
votes
6 answers

IntelliJ not seeing resources folder

I created a new Project from scratch in IntelliJ by using a Maven Module. I didn't select any specific archetypes and I clicked on finish. The project gets created nicely and I have the java and resources folders under src/main as…
Marsellus Wallace
  • 17,991
  • 25
  • 90
  • 154
15
votes
3 answers

Visual Studio 2013 (vs120) asks for wrong boost libraries

I'm trying to compile one of my projects on Windows 7, using Visual Studio 2013. I've installed Boost 1.53 and setup the solution using cmake. What happens is that now the compiled libraries of boost are in the form…
Svalorzen
  • 5,353
  • 3
  • 30
  • 54
14
votes
5 answers

iPhone - ShareKit , SHK.m giving the compiler error for FileNot Found

I am facing the issue while compiling my iphone project with ShareKit Integrated .I was working on that , everything was working fine till now , all of a sudden now its giving me the error. In SHK.m file , #import …
Bharat Jagtap
  • 1,692
  • 2
  • 22
  • 35
1
2 3
40 41