Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Invalid Python config directory

Posted on 2008-12-23
4
Medium Priority
?
1,549 Views
Last Modified: 2012-05-06
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:\.
0
Comment
Question by:JoshuaPHG
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 1

Author Comment

by:JoshuaPHG
ID: 23236738
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
 
LVL 15

Accepted Solution

by:
efn earned 750 total points
ID: 23237096
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
 
LVL 1

Author Comment

by:JoshuaPHG
ID: 23237291
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
 
LVL 1

Author Comment

by:JoshuaPHG
ID: 23237445
Replaced userDir = os.getcwd() with  userDir = 'C:\\Documents and Settings\\' + os.getenv('username')

I'm a little happier now.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Progress

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question