Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem creating an archive
#1
Hi everyone, first of all, sorry if my english is quite poor.

I'm new into programming and python, and today, I found my first newbie problem that I can't solve, even after I googled it a lot.


I'm trying to create a text file that doesn´t exist in the working directory, with this:

file = open('file.txt', 'w')
Or with this one:

file = open('file.txt', 'w+')
In every case I get the same error:
FileNotFoundError: [Errno 2] No such file or directory: 'file.txt'


I understood that, if I use that code, the program will open the file, and if it doesn't exists, it will create it.
I've tried a lot of things, like reinstalling VS Code, Python, checked the paths, checked the directory permissions, but nothing works, and I can't find the solution.

Thank you in advance!
Reply


Messages In This Thread
Problem creating an archive - by trojantrojan - May-10-2020, 12:18 AM
RE: Problem creating an archive - by bowlofred - May-10-2020, 12:57 AM
RE: Problem creating an archive - by mwd1993 - May-10-2020, 01:16 AM
RE: Problem creating an archive - by trojantrojan - May-10-2020, 01:32 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Extract and rename a file from an Archive tester_V 4 4,298 Jul-08-2024, 07:54 AM
Last Post: tester_V
  Extracting specific file from an archive tester_V 4 3,193 Jan-29-2024, 06:41 PM
Last Post: tester_V
  Installing Pillow from remote archive in Linux Flatpak ChrisOfBristol 6 3,065 Sep-23-2022, 07:48 PM
Last Post: ChrisOfBristol
  Creating a TG crypto Bot_ problem when trying to with bot.polling p1ner0 1 2,422 Apr-27-2022, 03:43 AM
Last Post: p1ner0
  Find specific file in an archive tester_V 8 5,111 Feb-13-2021, 06:13 PM
Last Post: tester_V
  Problem in creating a vector termo 11 6,040 Oct-10-2019, 03:09 PM
Last Post: stullis
  Invalid archive error when attempting to install dash bootstrap components meaydemi 0 5,673 Jul-11-2019, 05:49 PM
Last Post: meaydemi
  Create file archive that contains crypto hash ED209 1 2,830 May-29-2019, 03:05 AM
Last Post: heiner55
  Archive (.7z, .zip, .rar, .tar, etc) Password Extractor btforensics 1 7,543 Jul-08-2018, 08:29 PM
Last Post: Larz60+
  Problem while creating an Excel File using python Math_Enthusiast 3 4,222 Dec-09-2017, 08:49 PM
Last Post: buran

Forum Jump:

User Panel Messages

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