Python Forum
FileNotFoundError: [Errno 2] No such file or directory:
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
FileNotFoundError: [Errno 2] No such file or directory:
#1
Hello, I have this FileNotFoundError and I need help

global data
headers = open("C:\\Users\\sazug\\OneDrive\\Desktop\\DDOS\\hammer\\headers\\headers.txt", "r")
data = headers.read()
headers.close
This DDoS project is just for educational purposes and I'm testing it on my own network
and also I want to learn more stuff about this project but this error doesn'tlet me so please help.



Error:
Traceback (most recent call last): File "Hammer.py", line 120, in <module> headers = open("C:\\Users\\sazug\\OneDrive\\Desktop\\DDOS\\hammer\\headers\\headers.txt", "r") FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\sazug\\OneDrive\\Desktop\\DDOS\\hammer\\headers\\headers.txt'
Thank You!
Reply
#2
check that file exists at that location
as a side note for code like this global data is not necessary. And using globals is generally discouraged.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
(Nov-02-2020, 12:24 PM)buran Wrote: check that file exists at that location
as a side note for code like this global data is not necessary. And using globals is generally discouraged.


the file exists in the directory but still doesn't work
Reply
#4
you cannot argue with the interpreter - if it says it's not there, then there is some problem that you cannot see
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#5
(Nov-02-2020, 12:36 PM)buran Wrote: you cannot argue with the interpreter - if it says it's not there, then there is some problem that you cannot see

Okay, I will check the whole code, Thanks for helping <3
Reply
#6
for example - it look suspicious you have a sub-folder Desktop inside folder OneDrive. Not that it's not possible that you have created such folder inside OneDrive folder, but still suspicious
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#7
(Nov-02-2020, 12:44 PM)buran Wrote: for example - it look suspicious you have a sub-folder Desktop inside folder OneDrive. Not that it's not possible that you have created such folder inside OneDrive folder, but still suspicious

It did it by itself
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Unable to resolve FileNotFoundError llarkin6 6 1,806 Sep-29-2025, 05:45 PM
Last Post: noisefloor
  subprocess FileNotFoundError: [Errno 2] No such file or directory: Pedroski55 11 2,556 Aug-07-2025, 02:10 AM
Last Post: Pedroski55
  FileNotFoundError: [Errno 2] No such file or directory although the file exists Arnibandyo 0 2,846 Aug-12-2024, 09:11 AM
Last Post: Arnibandyo
  "[Errno 2] No such file or directory" (.py file) IbrahimBennani 13 14,741 Jun-17-2024, 12:26 AM
Last Post: AdamHensley
  Error (Errno 2), File upload with the Flask framework and a public IP Username_Python1 0 2,050 Mar-28-2024, 01:46 PM
Last Post: Username_Python1
  FileNotFoundError: [WinError 2] The system cannot find the file specified NewBiee 2 3,973 Jul-31-2023, 11:42 AM
Last Post: deanhystad
  Using pyinstaller with .ui GUI files - No such file or directory error diver999 3 11,603 Jun-27-2023, 01:17 PM
Last Post: diver999
  Extract file only (without a directory it is in) from ZIPIP tester_V 1 5,877 Jan-23-2023, 04:56 AM
Last Post: deanhystad
Thumbs Up Need to compare the Excel file name with a directory text file. veeran1991 1 2,903 Dec-15-2022, 04:32 PM
Last Post: Larz60+
  no such file or directory in SFTP saisankalpj 2 3,465 Nov-25-2022, 11:07 AM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020