473,811 Members | 2,485 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Windows XP os.chdir() path problem...

GTXY20
29 New Member
Hi there,

I have been pulling my hair out with the following error - here is the code:

Expand|Select|Wrap|Line Numbers
  1. os.chdir("..\data")
  2. uhdatafile = open("%s.txt" % self.datafile, 'r')
  3.  
which gives me the following error:

Expand|Select|Wrap|Line Numbers
  1. WindowsError: [Error 2] The system cannot find the file specified: 'C:\\Documents and Settings\\HHG\\Desktop\\Reportsdata
  2.  
can anyone shed soem light, I have imported os and I have also tried indicating \\data, /data, //data.

Thanks so much.

G.
Oct 12 '07 #1
4 11846
bartonc
6,596 Recognized Expert Expert
Hi there,

I have been pulling my hair out with the following error - here is the code:

Expand|Select|Wrap|Line Numbers
  1. os.chdir("..\data")
  2. uhdatafile = open("%s.txt" % self.datafile, 'r')
  3.  
which gives me the following error:

Expand|Select|Wrap|Line Numbers
  1. WindowsError: [Error 2] The system cannot find the file specified: 'C:\\Documents and Settings\\HHG\\Desktop\\Reportsdata
  2.  
can anyone shed soem light, I have imported os and I have also tried indicating \\data, /data, //data.

Thanks so much.

G.
use raw strings for Windows path variables!
Expand|Select|Wrap|Line Numbers
  1. os.chdir(r"..\data")
  2. uhdatafile = open("%s.txt" % self.datafile, 'r')
  3.  
Also look at
normpath( path)

Normalize a pathname. This collapses redundant separators and up-level references so that A//B, A/./B and A/foo/../B all become A/B. It does not normalize the case (use normcase() for that). On Windows, it converts forward slashes to backward slashes. It should be understood that this may change the meaning of the path if it contains symbolic links!
Oct 12 '07 #2
bartonc
6,596 Recognized Expert Expert
use raw strings for Windows path variables!
Expand|Select|Wrap|Line Numbers
  1. os.chdir(r"..\data")
  2. uhdatafile = open("%s.txt" % self.datafile, 'r')
  3.  
Also look at
Expand|Select|Wrap|Line Numbers
  1. >>> os.getcwd()
  2. 'D:\\My Documents\\HETAP Project\\2.13a'
  3. >>> os.path.normpath('..')
  4. '..'
  5. >>> os.path.abspath('..')
  6. 'D:\\My Documents\\HETAP Project'
  7. >>> 
  8. >>> os.path.abspath(r'..\2.12a')
  9. 'D:\\My Documents\\HETAP Project\\2.12a'
  10. >>> os.path.abspath('..\2.12a')
  11. 'D:\\My Documents\\HETAP Project\\2.13a\\..\x02.12a'
  12. >>> os.path.abspath('..\\2.12a')
  13. 'D:\\My Documents\\HETAP Project\\2.12a'
  14. >>> 
Oct 12 '07 #3
GTXY20
29 New Member
Perfect - thank you.
Oct 12 '07 #4
bartonc
6,596 Recognized Expert Expert
Perfect - thank you.
Any time .
Oct 12 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
6752
by: | last post by:
Hi, I have a Windows Service that uses a referenced dotnet-dll. In my dll I set some public string to a stringvalue that I get from reading a xml-file(my config file). It works fine if I use it in a vb-form. But since Windows Services ? executes? in windows\system32 I can´t locate my xml-config- file. I don´t want to set different "compiling-statements" such as :
1
3121
by: William Starr Moake | last post by:
Another problem with absolute paths in the WYSIWYG editor I'm putting together. The function to toggle between WYSIWYG and HTML modes works except for one glitch. If you use a relative path for a link, like <a href="download.htm">Click Here</a>, the editor returns an absolute path the second time you toggle HTML mode: <a href="C:\Windows\Desktop\Editor\download.htm" and even adds file:/// on the third try. This path must be manually...
9
2136
by: Grant Edwards | last post by:
I have several python apps (some wxPython, some plain text-mode stuff) that I distribute internally for installation on Win32 machines. They're bundled/installed using py2exe and inno setup. I followed what I think is the normal procedure of installing each app in its own directory under /Program Files/<vendor>/<app>. The problem is that the apps only run if they're started with
6
3433
by: Laszlo Zsolt Nagy | last post by:
Sorry, I realized that the import zlib was not executed from my (working) service. So here is the question: why can't I use zlib from a win32 service? Is there any way to make it working? >------------- >Python could not import the service's module > File "T:\Python\Projects\NamedConnector\Service.py", line 17, in ? > from Processor import * > File "c:\Python\Projects\NamedConnector\Processor.py", line 35, in ?
4
3334
by: gnah | last post by:
Greetings, I hope my problem is easy to fix, I'm pretty new with php - but I am getting weird results with the opendir() function. It may just be a path problem, but I don't see which variable to change. here are some tests I did to see what was wrong: $blah = opendir("blocks"); while ($file = readdir($blah)) {
3
11015
by: route_coder | last post by:
I am using access database to create a crystal report in VB.NET Everything works fine when I run on my machine. But when I am deploying it other windows machines. It is asking for database server name and logon information. The problem which I understood from this is that the path is hardcoded in the crystal report and the database is in my bin folder. when I run my app on other machines it is looking for the database in that folder and...
0
870
by: Ingo Eichenseher | last post by:
I've the follwing configuration: <httpHandlers> <add verb="GET" path="FilmImage.jpg" type="oaky.ImageHandler" validate="false"/> </httpHandlers> IIS is configured to handle '.jpg' via aspnet_iisapi.dll This works perfectly under XP(IIS 5.1) (.NET 1.1 and 2.0) and also under
1
2874
by: gnewsgroup | last post by:
I have a user control called Footer.ascx, in which a background image is inserted like so: <div id="footerdiv" style="background-image:url('Images/ mybackground.jpg'); background-position:center; background-repeat:no- repeat;" <!-- My footer content goes here. --</div> This Footer.ascx is under a folder called /UserControls (the leading forward slash indicates the root of the web application, same below).
6
17038
by: Marcin201 | last post by:
Is there an built-in functionality in python to convert Windows paths to Unix paths? I am running into problems when creating data files on Windows and the running them on a Unix platform. I create paths using os.path.join. os.path.join('Pictures', '01.jpg') returns 'Pictures\\01..jpg' on Win. When I read files created on Win under Unix this is a problem, python cannot open 'Pictures\\01.jpg' Thanks,
0
9728
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
10389
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
10402
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,...
1
7670
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...
0
6890
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5554
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4339
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3867
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.