Directory is Not Getting Made Correctly in Python Script with os.makedirs

~ is a string, so it is not going the evaluated as expected.
You can make use of expanduser to get the user’s home directory:

import os

def ensure_dir():
    home = os.path.expanduser("~")
    if platform.system() == ('Windows'):
        chromeDir = os.path.join(home, '/Drivers/Google/Chrome/chromedriver')
        if not os.path.exists(chromeDir):
            ...

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top