unable to import os

K

ktxn1020

Hi Experts,

I built a scrip file which cleans up the old log files starting from
the oldest till the necessary free space on the drive reaches.

The script ran well independently using Python's Integrated
Development Environment version 2.4.1. When it is called from Borland
C++ Builder 5 with python for delphi version 3.16, it is complained at
the line "import os", but not at the line "import nt". How can
I resolve this?

I wonder if there is a built_in command in NT OS specific to get date
and time of a file. The following command is what I used in my script
mtime = os.stat(Path + file_name)[os.path.stat.ST_MTIME]
 
F

Fredrik Lundh

ktxn1020 said:
The script ran well independently using Python's Integrated
Development Environment version 2.4.1. When it is called from Borland
C++ Builder 5 with python for delphi version 3.16, it is complained at
the line "import os", but not at the line "import nt". How can
I resolve this?

that means that the python path is messed up, so Python cannot
find it's support libraries (usually found under c:/python24/Lib).

I have no idea what "Python for Delphi 3.16" is, so things may be
different for that distribution (if that's what it is).

adding

import sys
print sys.path

and comparing that to the actual file structure may help you figure
out what's going on.
I wonder if there is a built_in command in NT OS specific to get date
and time of a file. The following command is what I used in my script
mtime = os.stat(Path + file_name)[os.path.stat.ST_MTIME]

fwiw, that's usually spelled os.path.getmtime in contemporary python.

if you cannot import os, you can use

mtime = nt.stat("q.py")[8]

but it's probably better to fix the path issue; Python doesn't work well
without the support library.

</F>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,264
Messages
2,571,326
Members
48,013
Latest member
fmb_amith

Latest Threads

Top