Python Forum
os.path.exists apparently doesn't always work!
Thread Rating:
  • 2 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
os.path.exists apparently doesn't always work!
#1
This code should sense that there is no data sub-directory,
and create it, but it doesn't on windows 7, but I swear it worked in the past.

I guess i could use shutil

import os

datapath = f'{os.path.abspath(os.getcwd())}\\data'
if not os.path.exists(datapath):
    print('creating path')
    os.makedirs(datapath)
else:
    print('path exists')
Reply


Messages In This Thread
os.path.exists apparently doesn't always work! - by Larz60+ - Oct-10-2017, 10:10 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Why wont this path work one way, but will the other way? cubangt 2 693 Sep-01-2023, 04:14 PM
Last Post: cubangt
  Why doesn't calling a parent constructor work with arbitrary keyword arguments? PurposefulCoder 4 984 Jun-24-2023, 02:14 PM
Last Post: deanhystad
  Why doesn't this code work? What is wrong with path? Melcu54 7 1,875 Jan-29-2023, 06:24 PM
Last Post: Melcu54
  color code doesn't work harryvl 1 926 Dec-29-2022, 08:59 PM
Last Post: deanhystad
  client.get_all_tickers() Doesn't work gerald 2 1,749 Jun-16-2022, 07:59 AM
Last Post: gerald
  pip doesn't work after Python upgrade Pavel_47 10 4,289 May-30-2022, 03:31 PM
Last Post: bowlofred
  For Loop Works Fine But Append For Pandas Doesn't Work knight2000 2 2,057 Dec-18-2021, 02:38 AM
Last Post: knight2000
  Class Method to Calculate Age Doesn't Work gdbengo 1 1,731 Oct-30-2021, 11:20 PM
Last Post: Yoriz
  Process doesn't work but Thread work ! mr_byte31 4 2,670 Oct-18-2021, 06:29 PM
Last Post: mr_byte31
  WebDriverException: Message: 'PATH TO CHROME DRIVER' executable needs to be in PATH Led_Zeppelin 1 2,239 Sep-09-2021, 01:25 PM
Last Post: Yoriz

Forum Jump:

User Panel Messages

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