Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8533843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:03:34+00:00 2026-06-11T10:03:34+00:00

I am trying to open the file recentlyUpdated.yaml from my Python script. But when

  • 0

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 problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:03:35+00:00Added an answer on June 11, 2026 at 10:03 am
    • Ensure the file exists (and has the right file extension): use os.listdir() to see the list of files in the current working directory.
    • Ensure you’re in the expected directory using os.getcwd().
      (If you launch your code from an IDE, you may be in a different directory.)
    • You can then either:
      • Call os.chdir(dir) where dir is the directory containing the file. Then, open the file using just its name, e.g. open("file.txt").
      • Specify an absolute path to the file in your open call.
    • Use a raw string (r"") if your path uses backslashes, like
      so: dir = r'C:\Python32'

      • If you don’t use raw string, you have to escape every backslash: 'C:\\User\\Bob\\...'
      • Forward-slashes also work on Windows 'C:/Python32' and do not need to be escaped.

    Let me clarify how Python finds files:

    • An absolute path is a path that starts with your computer’s root directory, for example C:\Python\scripts if you’re on Windows.
    • A relative path is a path that does not start with your computer’s root directory, and is instead relative to something called the working directory. You can view Python’s current working directory by calling os.getcwd().

    If you try to do open('sortedLists.yaml'), Python will see that you are passing it a relative path, so it will search for the file inside the current working directory.

    Calling os.chdir() will change the current working directory.

    Example: Let’s say file.txt is found in C:\Folder.

    To open it, you can do:

    os.chdir(r'C:\Folder')
    open('file.txt') # relative path, looks inside the current working directory
    

    or

    open(r'C:\Folder\file.txt') # absolute path
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Specifically I am trying to open a file from SharePoint, but it's really just
I'm trying to open a zip file with jython using FileInputStream and ZipInputStream. But
I'm trying to open a file with Python, but I'm unsure how to find
I'm trying to open a write-protected ms excel 2007 file using win32com in python
I am trying to open a file through python that once it is open
When trying to open a file using this command: $fd = fopen('majestic_files/majestic_record.txt','w'); I get
I'm trying to open a file, and read from it.. but I'm having some
I'm trying to open a file using fopen, and I am getting the error:
I'm trying to open a file using MacVim 7.3 (53) from the command line
I am trying to open file in external editor from java, but when i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.