Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5928475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:17:47+00:00 2026-05-22T14:17:47+00:00

I have an annoying problem in python 2.7 on windows XP. I’ve got some

  • 0

I have an annoying problem in python 2.7 on windows XP. I’ve got some code that collects a file name off the command line with the argparse library. I then try and open said file. Normally, this works fine, and if you pass in a full path name it successfully opens that too. However, if the path uses a drive letter other than the location you started from, python fails with an IO error, stating that the file or directory does not exist.

For example:

C:\>schema_split.py "C:\path\to\file"
works!
C:\>schema_split.py "I:\path\to\file"
fails!

Relevant code section:

parser = argparse.ArgumentParser(description='Process the Accounting file.', version='%(prog)s 1.1')
parser.add_argument('infile', nargs="+", type=str, help='list of input files')
# get the current arguments and put them into a variable
args = parser.parse_args()
for f in args.infile:
    with open(f, "rb") as mycsv:

I don’t know why python would have problems with alternate drive letters. The only thing I can come up with is that we run it on a shared drive mapped to a local drive. But for all intents and purposes, the program shouldn’t “see” the fact that it is operating on a remote drive.

Thoughts?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T14:17:48+00:00Added an answer on May 22, 2026 at 2:17 pm

    You are assuming python is having problems with drive letters. It isn’t. Your problem is something else.

    C:\>python
    Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> f = open(r"U:\foo.txt")
    >>> 
    

    As you can see opened a file from another drive using backslashes without error.

    Use the following script to diagnose your problem:

    import os
    import sys
    
    path = sys.argv[1]
    basepath, fname = os.path.split(path)
    print "directory:", basepath
    if os.path.exists(basepath):
        print "directory exists"
    else:
        print "directory does not exist!"
        sys.exit()
    
    if not fname:
        print "no filename provided!"
        sys.exit()
    print "filename:", fname
    if os.path.exists(path):
        print "filename exists"
    else:
        print "filename not found!"
        print "directory contents:"
        for fn in os.listdir(basepath):
            print fn
    

    Pass your path to the script and it will test the path and file name you pass to it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have come across an annoying problem while writing some PHP4 code. I renamed
I have an interesting/annoying problem with some VBScripts running on Windows 2003 Server (they
I have encountered a most annoying problem that occurs on the PWD variable when
I have a layout that is working, but it has one very annoying problem..
I have a weird, annoying problem with Python 2.6. I'm trying to run this
I have an app that is nearly finished but encountered an annoying problem. In
Ive got a mega annoying problem I have a view with: @{ if(ViewBag.Section ==
I have a very frustrating python problem. In this code fixedKeyStringInAVar = SomeKey def
I have this annoying problem. I've used some kind of key combination and now
I'm having an annoying problem, that may have a simple answer! I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.