Python Forum
opening a file from a windows desktop folder- error opening file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
opening a file from a windows desktop folder- error opening file
#1
Hi Team,

I am trying to open a file that is available in the desktop folder with the below command but getting an error
that file is not present.

I don't have access to place the input file in the python folder to open the file.

code:
a=r'C:\Users\Charan\Desktop\Python\sample.txt'
b=open(a,'r')
error:
Error:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Charan\\Desktop\\Python\\sample.txt'
Reply
#2
it looks OK and should work given the file exists. Sorry, but can you confirm one more time that file with that name exists at the this location?
(Dec-06-2018, 01:03 AM)Charan007 Wrote: a file that is available in the desktop folder
i.e. is the file on the Desktop or in a Python folder on the Desktop?
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


Possibly Related Threads…
Thread Author Replies Views Last Post
  Error (Errno 2), File upload with the Flask framework and a public IP Username_Python1 0 108 1 hour ago
Last Post: Username_Python1
  MCU reboots after opening Serial port when ran from Raspberry PI zazas321 3 327 Mar-19-2024, 09:02 AM
Last Post: zazas321
Question How to add Python folder in Windows Registry ? Touktouk 1 206 Feb-20-2024, 01:04 PM
Last Post: DeaD_EyE
  Compare folder A and subfolder B and display files that are in folder A but not in su Melcu54 3 466 Jan-05-2024, 05:16 PM
Last Post: Pedroski55
  file open "file not found error" shanoger 8 942 Dec-14-2023, 08:03 AM
Last Post: shanoger
  error "cannot identify image file" part way through running hatflyer 0 612 Nov-02-2023, 11:45 PM
Last Post: hatflyer
  Need to replace a string with a file (HTML file) tester_V 1 699 Aug-30-2023, 03:42 AM
Last Post: Larz60+
  Reading a file name fron a folder on my desktop Fiona 4 851 Aug-23-2023, 11:11 AM
Last Post: Axel_Erfurt
  Rename files in a folder named using windows explorer hitoxman 3 692 Aug-02-2023, 04:08 PM
Last Post: deanhystad
  How can I change the uuid name of a file to his original file? MaddoxMB 2 868 Jul-17-2023, 10:15 PM
Last Post: Pedroski55

Forum Jump:

User Panel Messages

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