Link to home
Start Free TrialLog in
Avatar of JoshuaPHG
JoshuaPHGFlag for United States of America

asked on

Invalid Python config directory

I am troubleshooting an install of Python 2.5.2 for Windows XP.  I can open up the command line without issue. - My problem is wih IDLE.  I know nothing about python, this is strictly "playing".

At the command line in the python directory I can try to start IDLE:
C:\Python25> python Lib/idlelib/idle.py
Warning: unable to create user config directory F:\.idlerc Check path and permissions.

Where is this path F:\coming from?  It needs to be C:\.
Avatar of JoshuaPHG
JoshuaPHG
Flag of United States of America image

ASKER

I just temporarily set the %HOMEDRIVE% windows variable to C: and IDLE opened.  Aside from setting that, because it will screw up other things, where do I make that change in python?  I'm not gleaning anything from the config-main.def fille
ASKER CERTIFIED SOLUTION
Avatar of efn
efn

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I in the Lib/idlelib directory I changed the configHandler.py script that you indicated.

Original:

def GetUserCfgDir(self):
        """
        Creates (if required) and returns a filesystem directory for storing
        user config files.

        """
        cfgDir = '.idlerc'
        userDir = os.path.expanduser('~')
        if userDir != '~': # expanduser() found user home dir
            if not os.path.exists(userDir):
                warn = ('\n Warning: os.path.expanduser("~") points to\n '+
                        userDir+',\n but the path does not exist.\n')
                sys.stderr.write(warn)
                userDir = '~'
        if userDir == "~": # still no path to home!
            # traditionally IDLE has defaulted to os.getcwd(), is this adequate?
            userDir = os.getcwd()
        userDir = os.path.join(userDir, cfgDir)
        if not os.path.exists(userDir):
            try:
                os.mkdir(userDir)
            except (OSError, IOError):
                warn = ('\n Warning: unable to create user config directory\n'+
                        userDir+'\n Check path and permissions.\n Exiting!\n\n')
                sys.stderr.write(warn)
                raise SystemExit
        return userDir

New:

def GetUserCfgDir(self):
        """
        Creates (if required) and returns a filesystem directory for storing
        user config files.

        """
        cfgDir = '.idlerc'
        userDir = os.getcwd()
        #userDir = os.path.expanduser('~')
        #if userDir != '~': # expanduser() found user home dir
        #    if not os.path.exists(userDir):
        #        warn = ('\n Warning: os.path.expanduser("~") points to\n '+
        #                userDir+',\n but the path does not exist.\n')
        #        sys.stderr.write(warn)
        #        userDir = '~'
        #if userDir == "~": # still no path to home!
        #    # traditionally IDLE has defaulted to os.getcwd(), is this adequate?
        #    userDir = os.getcwd()
        userDir = os.path.join(userDir, cfgDir)
        if not os.path.exists(userDir):
            try:
                os.mkdir(userDir)
            except (OSError, IOError):
                warn = ('\n Warning: unable to create user config directory\n'+
                        userDir+'\n Check path and permissions.\n Exiting!\n\n')
                sys.stderr.write(warn)
                raise SystemExit
        return userDir

It works now, but I don't really like it.  Essentially everything is remmed out except for the os.getcwd() part.  Maybe I should just have my HOMEDRIVE changed...

Any other thoughts before I close it out?
Replaced userDir = os.getcwd() with  userDir = 'C:\\Documents and Settings\\' + os.getenv('username')

I'm a little happier now.