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:\.
LVL 1
JoshuaPHGAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
efnConnect With a Mentor Commented:
The message is coming from the GetUserCfgDir function in the IdleConf class.  To get the directory for the .idlerc file, it first calls os.path.expanduser('~').  This is supposed to get the pathname of your home directory.  If that doesn't work, it calls os.getcwd() to get the current directory.  You can try these commands in the Python interpreter to see what they generate in your environment.  You will have run "import os" first.  In my Windows XP environment, the first call yields my user directory under C:\Documents and Settings.  This is where the file is supposed to go according to the comments in config-main.def.

I realize that this doesn't solve your problem directly, but maybe you can figure out how to persuade Windows that your home directory is not F:.
0
 
JoshuaPHGAuthor Commented:
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
0
 
JoshuaPHGAuthor Commented:
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?
0
 
JoshuaPHGAuthor Commented:
Replaced userDir = os.getcwd() with  userDir = 'C:\\Documents and Settings\\' + os.getenv('username')

I'm a little happier now.
0
All Courses

From novice to tech pro — start learning today.