473,656 Members | 2,997 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 8815
On 8/3/07, ve***********@v-programs.com <ve***********@ v-programs.comwro te:
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 "SyntaxErro r: 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 "SyntaxErro r: 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
23027
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 but it doesn't actually list the contents of the dir I pass in. it always operates on the current dir (wherever the script is run) and I have to chdir beforehand. Is that how its supposed to work? If so what is the point in passing in a...
8
2445
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
3869
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 are on an ext3 filesystem. The real code this problem comes from takes a configured set of directories to deal with and walks through each of those directories using os.listdir(). Today, I accidentally ran across a directory containing three...
15
2572
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 propose to add an 'abs' keyword which would make os.listdir return the absolute path of files instead of a relative path. This would bring only advantages, I think.
2
3077
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): File "docBoxApp.py", line 129, in ? File "core\PollFiles.pyc", line 332, in doPoll File "core\PollFiles.pyc", line 47, in createFileList File "core\PollFiles.pyc", line 25, in addFolderFiles
2
2663
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 for Win & *nix ; best platform independent) Robert
6
5683
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 of doing this? Thanks!
6
3759
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 pgmdir="f:\code\python\pgmgallery" # where i have pgm files g2=listdir(pgmdir) i get the following error WindowsError: The filename, directory name, or volume
0
8380
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8296
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8816
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8710
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8497
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7310
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6162
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
2
1928
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1598
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.