Python Forum
file open "file not found error"
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
file open "file not found error"
#4
(Dec-13-2023, 09:46 AM)Pedroski55 Wrote: Ok, so where is the file exactly? a little more info would help resolve your problem!

Try this, then see if you can see your path and file.

import glob

# set your path here
path = '/home/pedro/summer2021/OMR/'
files = glob.glob(path + '/**', recursive=True)
for f in files:
    # shows all paths and files in path
    print(f)



see i used Path.cwd() function to get my path, then i used OPEN function to open the file. The file is in the workspace or project folder. File LOcation image <--- is the image of the file location.

Below is the code



from pathlib import Path
path1 = Path.cwd()
some_file = open(path1 / "Sample.txt")


also i tried opening a simple file using python console not via ide and i get the same result. may be there are some permissions missing or something?
Reply


Messages In This Thread
file open "file not found error" - by shanoger - Dec-13-2023, 08:31 AM
RE: file open "file not found error" - by shanoger - Dec-13-2023, 12:49 PM
RE: file open "file not found error" - by menator01 - Dec-13-2023, 11:49 AM
RE: file open "file not found error" - by shanoger - Dec-13-2023, 12:54 PM
RE: file open "file not found error" - by menator01 - Dec-13-2023, 01:27 PM
RE: file open "file not found error" - by shanoger - Dec-14-2023, 08:03 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to write variable in a python file then import it in another python file? tatahuft 4 1,084 Jan-01-2025, 12:18 AM
Last Post: Skaperen
  Trying to open depracated joblib file mckennamason 0 849 Sep-19-2024, 03:30 PM
Last Post: mckennamason
  JSON File - extract only the data in a nested array for CSV file shwfgd 2 1,206 Aug-26-2024, 10:14 PM
Last Post: shwfgd
  FileNotFoundError: [Errno 2] No such file or directory although the file exists Arnibandyo 0 1,264 Aug-12-2024, 09:11 AM
Last Post: Arnibandyo
  Module not found error even though installed NZGeorge 1 5,457 Jul-10-2024, 09:08 AM
Last Post: Larz60+
  "[Errno 2] No such file or directory" (.py file) IbrahimBennani 13 7,195 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 1,443 Mar-28-2024, 01:46 PM
Last Post: Username_Python1
  Absolute paths in subprocess - file not found kittyticker 4 3,539 Jan-28-2024, 10:37 PM
Last Post: kittyticker
  Open/save file on Android frohr 0 1,222 Jan-24-2024, 06:28 PM
Last Post: frohr
  error "cannot identify image file" part way through running hatflyer 0 2,109 Nov-02-2023, 11:45 PM
Last Post: hatflyer

Forum Jump:

User Panel Messages

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