Решаем ошибку error no such file or directory
Ошибка error no such file or directory (Ошибка: нет файла или каталога) возникает на различных устройствах и программах. Разберем возможные решения в некоторых случаях.
В любом случае, в первую очередь обратите внимание на наличие необходимого файла или папки, если он указан в ошибке.
Если ошибка возникает при запуске приложения и после появления ошибки загрузка прекращается, происходет «вылет», вероятно игра или приложение установлена с ошибкой, либо в установочном файле отсутствуют важные компоненты. Если файлы скачаны через торент, проверьте целостность ХЭШа. Для этого кликните на закачку правой кнопкой и нажмите «Пересчитать хэш».

Проверьте, соответствует ли разрядность вашей операционной и запускаемого приложения. К примеру, ошибка no such file or directory появится, если вы запускаете программу, предназначенную для 64-х битных систем в 86-битной Windows.
Так же проверьте, есть ли у выполняемой программы или скрипты все необходимые права на чтение и запись. В windows запустите программу от имени администратора.
При написании программ и скриптов обратите внимание на кириллические символы в пути к файлу или папке.
Эта статья очень обобщенная, но вы наверняка пришли с конкретной ошибкой. Просим вас внести свой вклад в сообщество и напишите свою ошибку error no such file or directory и название программы, в которой она возникает в комментариях ниже. Мы постараемся вам помочь.
No such file or directory? But the file exists!
I’ve downloaded a game (Shank) but the bin file doesn’t run. The error that is shown when I try to launch the executable is:
9 Answers 9
You’re probably trying to run a 32-bit binary on a 64-bit system that doesn’t have 32-bit support installed.
There are three cases where you can get the message “No such file or directory”:
- The file doesn’t exist. I presume you’ve checked that the file does exist (perhaps because the shell completes it).
- There is a file by that name, but it’s a dangling symbolic link.
- The file exists, and you can even read it (for example, the command file shank-linux-120720110-1-bin displays something like “ELF 32-bit LSB executable …”), and yet when you try to execute it you’re told that the file doesn’t exist.
The error message in this last case is admittedly confusing. What it’s telling you is that a key component of the runtime environment necessary to run the program is missing. Unfortunately, the channel through which the error is reported only has room for the error code and not for this extra information that it’s really the runtime environment that’s to blame. If you want the technical version of this explanation, read Getting “Not found” message when running a 32-bit binary on a 64-bit system.
The file command will tell you just what this binary is. With a few exceptions, you can only run a binary for the processor architecture that your release of Ubuntu is for. The main exception is that you can run 32-bit (x86, a.k.a. IA32) binaries on 64-bit (amd64, a.k.a. x86_64) systems.
In Ubuntu up to 11.04, to run a 32-bit binary on a 64-bit installation, you need to install the ia32-libs package . You may need to install additional libraries (you’ll get an explicit error message if you do).
Since 11.10 (oneiric) introduced multiarch support, you can still install ia32-libs , but you can choose a finer-grained approach, it’s enough to get libc6-i386 (plus any other necessary library).
"No such file or directory" but it exists
I have no idea why the OS can’t even see the file when it’s there. Any thoughts?
![]()
19 Answers 19
This error can mean that ./arm-mingw32ce-g++ doesn’t exist (but it does), or that it exists and is a dynamically linked executable recognized by the kernel but whose dynamic loader is not available. You can see what dynamic loader is required by running ldd /arm-mingw32ce-g++ ; anything marked not found is the dynamic loader or a library that you need to install.
If you’re trying to run a 32-bit binary on an amd64 installation:
- Up to Ubuntu 11.04, install the package ia32-libs .
- On Ubuntu 11.10, install ia32-libs-multiarch .
- Starting with 12.04, install ia32-libs-multiarch , or select a reasonable set of :i386 packages in addition to the :amd64 packages.
![]()
I faced this error when I was trying to build Selenium source on Ubuntu. The simple shell script with correct shebang was not able to run even after I had all pre-requisites covered.
I opened the file in Vim and I could see that just because I once edited this file on a Windows machine, it was in DOS format. I converted the file to Unix format with below command:
I hope that we should take care whenever we edit files across platforms we should take care for the file formats as well.
![]()
![]()
This error may also occur if trying to run a script and the shebang is misspelled. Make sure it reads #!/bin/sh , #!/bin/bash , or whichever interpreter you’re using.
![]()
I had the same error message when trying to run a Python script — this was not @Warpspace’s intended use case (see other comments), but this was among the top hits to my search, so maybe somebody will find it useful.
In my case it was the DOS line endings ( \r\n instead of \n ) that the shebang line ( #!/usr/bin/env python ) would trip over. A simple dos2unix myfile.py fixed it.
I found my solution for my Ubuntu 18 here.
I got this error “No such file or directory” but it exists because my file was created in Windows and I tried to run it on Ubuntu and the file contained invalid 15\r where ever a new line was there. I just created a new file truncating unwanted stuff
As mentioned by others, this is because the loader can’t be found, not your executable file. Unfortunately the message is not clear enough.
You can fix it by changing the loader that your executable uses, see my thorough answer in this other question: Multiple glibc libraries on a single host
Basically you have to find which loader it’s trying to use:
Then find the right path for an equivalent loader, and change your executable to use the loader from the path that it really is:
You will probably need to set the path of the includes too, you will know if you want it or not after you try to run it. See all the details in that other thread.
I got the same error for a simple bash script that wouldn’t have 32/64-bit issues. This is possibly because the script you are trying to run has an error in it. This ubuntu forum post indicates that with normal script files you can add sh in front and you might get some debug output from it. e.g.
and see if you get any output.
In my case the actual problem was that the file that I was trying to execute was in Windows format rather than Linux.
![]()
Below command worked on 16.4 Ubuntu
This issue comes when your .sh file is corrupt or not formatted as per unix protocols.
dos2unix converts the .sh file to Unix format!
![]()
I had the same problem with a file that I’ve created on my mac. If I try to run it in a shell with ./filename I got the file not found error message. I think that something was wrong with the file.
open a ssh session to the server
cat filename
copy the output to the clipboard
rm filename
touch filename
vi filename
i for insert mode
paste the content from the clipboard
ESC to end insert mode
:wq!
This worked for me.
Added here for future reference (for users who might fall into the same case): This error happens when working on Windows (which introduces extra characters because of different line separator than Linux system) and trying to run this script (with extra characters inserted) in Linux. The error message is misleading.
In Windows, the line separator is CRLF (\r\n) whereas in linux it is LF (\n). This can be usually be chosen in text editor.
In my case, this happened due to working on Windows and uploading to Unix server for execution.
![]()
I just had this issue in mingw32 bash . I had execuded node/npm from Program Files (x86)\nodejs and then moved them into disabled directory (essentially removing them from path). I also had Program Files\nodejs (ie. 64bit version) in path, but only after the x86 version. After restarting the bash shell, the 64bit version of npm could be found. node worked correctly all the time (checked with node -v that changed when x86 version was moved).
I think bash -r would’ve worked instead of restarting bash: https://unix.stackexchange.com/a/5610
I had this issue and the reason was EOL in some editors such as Notepad++. You can check it in Edit menu/EOL conversion. Unix(LF) should be selected. I hope it would be useful.
Hit this error trying to run terraform/terragrunt (Single go binary).
Using which terragrunt to find where executable was, got strange error when running it in local dir or with full path
Problem was that there was two installations of terragrunt, used brew uninstall terragrunt to remove one fixed it.
After removing the one, which terragrunt showed the new path /usr/bin/terragrunt everything worked fine.
![]()
For those encountering this error when running a java program, it’s possible that you’re trying to run a 64-bit java program using on a 32-bit linux operating system.
I only realised when I ran ldd on 64-bit java which reported:
‘not a dynamic executable’
Whereas the old 32 bit java reported sensible results:
In my case, it turns out the file was a symlink:
Misleading errors like this are fairly common on Linux. Related discussion: https://lwn.net/Articles/532771/
Give it a try by changing the name of file or folder which is not showing in terminal/command prompt.
step1 : change the name of file or folder. step2 : cd filename/foldername
For future readers, I had this issue when trying to launch a Django server using gunicorn. I was using AWS CodeBuild to build the virtual environment and run tests and using CodeDeploy to put the built artifacts onto the production server and launch the new version (all environments were Ubuntu 20.04). I had mistakenly thought that env/bin/. contained actual binaries of native libraries but that was not the case. It was just Python scripts with a shebang of the path to the Python interpreter on the build machine. In my case, the machine installing the packages and actually running the packages was different. To be more specific, all of the files in env/bin had the shebang #!/codebuild/output/src715682316/src/env/bin/python , so of course running env/bin/gunicorn on the production server would fail. The cryptic error message was when Ubuntu would tell me that env/bin/gunicorn didn’t exist as opposed to saying /codebuild/output/src715682316/src/env/bin/python didn’t exist. I was able to fix this problem by starting gunicorn using python3 env/bin/gunicorn instead of env/bin/gunicorn .
In a .sh script, each line MUST end with a single character — newline ( LF or " \n ").
Don’t make mistakes like me, because my text-editor of choice is Notepad++ in Win.
Python No Such File Or Directory
Python FileNotFoundError: [Errno 2] No Such File Directory
The best way to examine this type of error is to look at the first block of the error message.
Any error that starts with the FileNotFoundError block means that Python cannot find the file specified.
This forces Python to terminate as it cannot process the preceding code without accessing the specified file.
It is a built-in exception that is raised by the OS module when a requested file or directory does not exist. You can also raise this error manually, but that’s an article for another day.
NOTE: This error is not raised in operations such as creating new files or writing content to a file that does not exist,
Let us take an example code that will throw the FileNotFoundError.
from os import listdir
for f in listdir ( ‘/non_existing_dir’ ) :
in the example above, we start by importing the listdir function from the os module. Next, we print each file in the specified directory of the listdir() function.
Since the target directory does not exist, Python will return an error as:
FileNotFoundError: [WinError 3] The system cannot find the path specified: ‘/non_existing_dir’
FileNotFoundError: [Errno 2] No such file or directory: ‘/non_existing_dir’
As you can see, the code fails to execute as Python cannot find the set directory.
Possible Causes
There are three major causes of the FileNotFoundError in Python.
- The directory or filename has been misspelled.
- Incorrect file path or directory path
- Use of relative paths.
Solutions
The solutions are simple.
- Ensure that the full filename and directory name are spelled correctly, including the extension.
- Second, always make sure that the path you are specifying exists and is accessible.
- Python will not resolve relative paths. For example, instead of using the tilde (
In our example above, we can resolve the FileNotFoundError by creating the target directory as:
We can then re-run the code as shown:
The program should return the files and directory in that directory as:
Conclusion
In this article, we discussed how to resolve the Python No Such File Or Directory error and how to resolve it.
About the author

John Otieno
My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list