zlib + Windows 32 service problem (ImportError)
Laszlo Zsolt Nagy
gandalf at geochemsource.com
Wed Aug 17 05:26:24 EDT 2005
|
>|
>C:\Python24;C:\Python24\DLLs;c:\Python24\Lib\site-packages\win32;c:\oracle\product\10.1.0\db_1\bin;c:\oracle\product\10.1.0\db_1\jre\1.4.2\bin\client;c:\oracle\product\10.1.0\db_1\jre\1.4.2\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program
>| Files\Common Files\GTK\2.0\bin
>|
>| Then I restarted my computer. It is still missing initzlib. :-(
>| Please note that I can run the same program as an application, logged in
>| as the same user.
>|
>| Les
>
>Changing the Windows dll search path doesn't make any difference. It is
>sys.path (Python's search path) that's causing you the headache. Please see
>the mentioned thread for proposed solutions.
>
>
Great. I could make my service working with this snippet:
import sys
sys.path.insert(0,r'C:\Python24\DLLs')
But this is very ugly. Primarily, I do not want to use absolute path
names in a this program. I want to use the same code on different
computers and operating systems, but this code is not portable.
Secondly, I do not understand why sys.path is different when I start
python interactively. I believe that sys.path should be the same when
starting the program as a service. The only difference between the
application and the service is that the 'main' program of the service
imports some additional modules. See them below.
iT:\Python\Projects\NamedConnector>python
Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>>
>>> s1 = str(sys.path)
>>>
>>> import win32serviceutil, win32service
>>> import pywintypes, win32con, winerror
>>> from win32event import *
>>> from win32file import *
>>> from win32pipe import *
>>> from win32api import *
>>> from ntsecuritycon import *
>>>
>>>
>>> s2 = str(sys.path)
>>>
>>> print s1 == s2
True
I cannot distribute my service until I make it independent of the python
installation directory.
Why sys.path is different when starting the code as a windows service?
How can I make this code portable?
By the way, you have been a great help. Thank you very much. I can now
continue working. :-)
Les
More information about the Python-list
mailing list