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
2
votes
0 answers

MSBuild says XML doc file (created from C# comments) does not exist, but it exists prior to build

When I set the property on a MSBuild project, the CoreCompile task is always executed, even when all files are present and up-to-date. MSBuild says it runs the CoreCompile task because th file "C:\Users\Georges\Documents\Visual…
Suzanne Soy
  • 3,027
  • 6
  • 38
  • 56
2
votes
3 answers

Xcode 4 - renamed/deleted file, yet get 'file not found' error

I just used Xcode's refactoring tool to rename a core data class from Player to Person. After fixing about 100 errors resulting from using dot notation that Xcode missed in the rename, I got to the last one: Player.m - Lexical or Preprocessor issue…
arsenius
  • 12,090
  • 7
  • 58
  • 76
2
votes
2 answers

Replace a XML File in a JAR File

Im am trying to replace a XML file while executing the JAR File. But Currently It comes with with an Java IO File not Found Exception. But i doubled Check the Path and it is correct. I am wondering if it is possible to replace a xml file within an…
user1414056
  • 41
  • 2
  • 5
1
vote
1 answer

ld: After successful linking shared lib not found on execution

I am currently working on a simple data synchonizer in a mixture of Fortran and C/C++ by using OpenMPI libraries. The synchonizer compiles and links correctly, as far as I can see: f95 -o fortran_mpi_test *.o…
user946924
  • 65
  • 6
1
vote
0 answers

grails wsclient "file not found" consuming a .net web service

first of all, I want to apologize if my question is stupid, but I'm really new in consuming .net web service in grails. There's a SOAP WS (wich I can't manipulate in any way) that I consume whis way: def wsdlURL =…
Johnny C.
  • 368
  • 1
  • 5
  • 20
1
vote
4 answers

Error: Could not find or load main class- Novice

Hi I am a novice in JAVA. I have been getting this file not found exception inspite of the file existing in the very location I have specified in the path which is Initially I had the issue of file not found. However, after performing a clean and…
ExceptionHandler
  • 213
  • 1
  • 8
  • 24
1
vote
0 answers

file not found when using DistributedCache on Hadoop

I have a fileNotFound problem using code below, this is a simple test of distributedCache, I don't know what is the problem? The path of the file is right, but I can not find files on datanode: package mapJoinTest2; /* * this is for map join using…
1
vote
1 answer

Nextflow is running executable inside docker container volume, but can't find it

I'm working on a nextflow pipeline, that uses a different docker container in each process. It looks something like this: params.exeA = "$projectDir/bin/exeA" //is inside docker volume of containerA params.exeB = "$projectDir/bin/1.0/exeB" //is…
Derk
  • 11
  • 2
1
vote
2 answers

How to get the correct path to a json file from the customtkinter module

I made my GUI using customtkinter. I used auto-py-to-exe to make it an file. The exe file doesn't open because of an theme json file missing error. The path to the correct file is…
Darkshadogt
  • 49
  • 1
  • 5
1
vote
1 answer

Visual Studio Code: FileNotFoundError. Execute in File Dir broken, and unable to access file's absolute path

I am trying to open a CSV file without using its absolute path, but I cannot access it because my files are located in /Users/foo/Machine Learning/Multiple Linear Regression/, which is a child of my working directory /Users/foo/Machine…
1
vote
1 answer

docker run --env-file /path/to/file.env fails with "no such file or directory"

I'm trying to run a docker image on a Debian server. The preproduced image has been pulled from Docker Hub. The cmd line is (stripped to the bones): sudo docker run -d -p 8190:433 --env-file /path/to/file.env my-image /path/to/file.env is similiar…
Recurs1on
  • 39
  • 1
  • 5
1
vote
1 answer

FileNotFoundError every time I try to download a video using PyTube

Every time I try to download a video using Pytube, it generates this error: FileNotFoundError: [Errno 2] No such file or directory: Recently it has been showing this error. Before, it worked completely fine. Here's my code: def vid_only(): for…
bliss
  • 23
  • 5
1
vote
1 answer

how to delete Arabic bad code file name with "$'\275'ڵ$'\343'.txt"

it is on ANDROID, from a decompress try by bsdtar on Termux, the bad code file name with 'ls' resulte is like "�ڵ�.txt" (copy&paste), and with 'ls' tab completion is like: $'\275'$J'\343.txt (the J is mimical of the Arabic…
J.Z
  • 927
  • 6
  • 4
1
vote
0 answers

FileNotFoundError: [Errno 2] File b'filepath.csv' does not exist:

I created a df to read a csv in my jupyter notebook library but for some reason the i'm getting an error like this: FileNotFoundError: [Errno 2] File b'file path/filename.csv' does not exist: b'/file path/filename.csv' My code is this: df_csv =…
bananas
  • 133
  • 8
1
vote
1 answer

The command i want to execute cannot find the file

I try to execute command in cmd from Python and save the output. I have the following code: import subprocess import matplotlib.pyplot as pyplot MyOut = subprocess.Popen("pytr portfolio", stdout=subprocess.PIPE, …
Din
  • 33
  • 6