473,503 Members | 1,831 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

os.listdir path error

Hello

Here is my simple listdir example:
>>import os
os.listdir("C:\Python24\") # This directory relly exists
Here is my error:

WindowsError: [Errno 3] The system cannot find the path specified: 'l/
*.*'

Regards,
Vedran

Aug 3 '07 #1
3 8733
On 8/3/07, ve***********@v-programs.com <ve***********@v-programs.comwrote:
Hello

Here is my simple listdir example:
>import os
os.listdir("C:\Python24\") # This directory relly exists

Here is my error:

WindowsError: [Errno 3] The system cannot find the path specified: 'l/
*.*'

That's a somewhat surprising error. Under 2.5, I get a more helpful
error message:
>>import os
os.listdir("C:\Python25\")
SyntaxError: EOL while scanning single-quoted string

That's because I've escaped the closing quote of the string with \".
Use this instead:
>>os.listdir("C:\\Python25\\")
or
>>os.listdir("C:/Python25/")
since windows is usually happy to use forward slashes instead of
backslashes in directory names.

--
Jerry
Aug 3 '07 #2
On Aug 3, 2:50 pm, vedrandeko...@v-programs.com wrote:
Hello

Here is my simple listdir example:
>import os
os.listdir("C:\Python24\") # This directory relly exists

Here is my error:

WindowsError: [Errno 3] The system cannot find the path specified: 'l/
*.*'

Regards,
Vedran
I get "SyntaxError: EOL while scanning single-quoted string", which is
what should happen when you escape the double-quotes at the end. Not
sure how you're getting that WindowsErrors.

If I do os.listdir('c:\python24') instead, it works fine.

Mike

Aug 3 '07 #3
ky******@gmail.com wrote:
>
I get "SyntaxError: EOL while scanning single-quoted string", which is
what should happen when you escape the double-quotes at the end. Not
sure how you're getting that WindowsErrors.

If I do os.listdir('c:\python24') instead, it works fine.
Yes, but only by accident. It will fail again if you try to do
os.listdir('c:\tmp'). You need to use the right quoting.
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Aug 5 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
23012
by: Jason Kratz | last post by:
OK. I've search on google groups and around the web for this and I haven't found an answer. I'm a Python newbie and have what I assume is a basic question. os.listdir takes a pathname as an arg...
8
2436
by: Hannu Kankaanp?? | last post by:
This may be a bug or simply a strange result of undefined behaviour, but this is what I get with Python 2.3.2 on Windows XP: >>> import os >>> os.listdir('') >>> os.listdir(u'')
0
465
by: Ishwor | last post by:
hi check your seperator variable in the os module. :) for example >>> import os >>> os.sep '\\' Now what you do is :- >> os.listdir("D:" + os.sep + "any_other_folder_name" + os.sep); :)
7
3855
by: Kenneth Pronovici | last post by:
I have some confusion regarding the relationship between locale, os.listdir() and unicode pathnames. I'm running Python 2.3.5 on a Debian system. If it matters, all of the files I'm dealing with...
15
2561
by: Riccardo Galli | last post by:
Hi, I noticed that when I use os.listdir I need to work with absolute paths 90% of times. While I can use a for cycle, I'd prefere to use a list comprehension, but it becomes too long. I...
2
3063
by: Thomas Thomas | last post by:
Hi All, I am trying to access a mapped network drive folder. everything works fine normally. But when i run the application as service I am getting the error Traceback (most recent call last):...
2
2656
by: robert | last post by:
I want to get the files and sizes and times etc. stats of a dir fast. os.listdir & iterating with os.stat seems not to run at optimal speed for network folders. Is there a faster possibility? (both...
6
5673
by: Soren | last post by:
Hi, I'd like to read the filenames in a directory, but not the subdirectories, os.listdir() gives me everything... how do I separate the directory names from the filenames? Is there another way...
6
3749
by: jimgardener | last post by:
hi i have a directory containing .pgm files of P5 type.i wanted to read the pixel values of these files ,so as a firststep i wrote code to make a list of filenames using listdir ...
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7280
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7330
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.