Python 3 script as windows service
up vote
0
down vote
favorite
I have a problem running my script as a service.
I don't understand what to do with paths.
What I have:
main.py (main code) service.py (template to install and run main.py
/ |
subdir/ subdir/ config.ini
script1.py script2.py
What in main.py:
1. I read config.ini and get variables with paths, i.e.:
[XLS]
dir = D:\ExcelToSQL
workbook1 = workbook1.xls
workbook2 = workbook2.xls
workbook3 = workbook3.xls
[SQL]
user = root
password = password
host = localhost
database = database
port = 3306
ssl_ca =
ssl_verify_cert =
ssl_key =
ssl_cert =
encoding =
- script1 for changing values in XLS workbooks just functions with args and params
script2 for importing inMySQL DB, again just functions.
All variables come fromconfig.ini
Main problem when I debug my service. It can't read config.ini:
Error 0xC0000003 - The instance's SvcRun() method failed
Traceback (most recent call last):
File "C:Pythonlibsite-packageswin32libwin32serviceutil.py", line 839, in SvcRun
self.SvcDoRun()
File "D:rs_alIdeaProjectsExcelToSQLPyXLSQLservice.py", line 31, in SvcDoRun
self.main()
File "D:rs_alIdeaProjectsExcelToSQLPyXLSQLservice.py", line 37, in main
app()
File "D:rs_alIdeaProjectsExcelToSQLPyXLSQLpyxlsql.py", line 14, in app
path = config.get ("XLS", "dir")
File "C:Pythonlibconfigparser.py", line 780, in get
d = self._unify_values(section, vars)
File "C:Pythonlibconfigparser.py", line 1146, in _unify_values
raise NoSectionError(section) from None
configparser.NoSectionError: No section: 'XLS'
(null): (null)
I know where is an issue:
in main.py:print(sys.argv[0])
outputC:Pythonlibsite-packageswin32PythonService.exe
Is it possible to run the service as I want? Because now it is looking for ini file in C:Pythonlibsite-packageswin32PythonService.exe.
python service
add a comment |
up vote
0
down vote
favorite
I have a problem running my script as a service.
I don't understand what to do with paths.
What I have:
main.py (main code) service.py (template to install and run main.py
/ |
subdir/ subdir/ config.ini
script1.py script2.py
What in main.py:
1. I read config.ini and get variables with paths, i.e.:
[XLS]
dir = D:\ExcelToSQL
workbook1 = workbook1.xls
workbook2 = workbook2.xls
workbook3 = workbook3.xls
[SQL]
user = root
password = password
host = localhost
database = database
port = 3306
ssl_ca =
ssl_verify_cert =
ssl_key =
ssl_cert =
encoding =
- script1 for changing values in XLS workbooks just functions with args and params
script2 for importing inMySQL DB, again just functions.
All variables come fromconfig.ini
Main problem when I debug my service. It can't read config.ini:
Error 0xC0000003 - The instance's SvcRun() method failed
Traceback (most recent call last):
File "C:Pythonlibsite-packageswin32libwin32serviceutil.py", line 839, in SvcRun
self.SvcDoRun()
File "D:rs_alIdeaProjectsExcelToSQLPyXLSQLservice.py", line 31, in SvcDoRun
self.main()
File "D:rs_alIdeaProjectsExcelToSQLPyXLSQLservice.py", line 37, in main
app()
File "D:rs_alIdeaProjectsExcelToSQLPyXLSQLpyxlsql.py", line 14, in app
path = config.get ("XLS", "dir")
File "C:Pythonlibconfigparser.py", line 780, in get
d = self._unify_values(section, vars)
File "C:Pythonlibconfigparser.py", line 1146, in _unify_values
raise NoSectionError(section) from None
configparser.NoSectionError: No section: 'XLS'
(null): (null)
I know where is an issue:
in main.py:print(sys.argv[0])
outputC:Pythonlibsite-packageswin32PythonService.exe
Is it possible to run the service as I want? Because now it is looking for ini file in C:Pythonlibsite-packageswin32PythonService.exe.
python service
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a problem running my script as a service.
I don't understand what to do with paths.
What I have:
main.py (main code) service.py (template to install and run main.py
/ |
subdir/ subdir/ config.ini
script1.py script2.py
What in main.py:
1. I read config.ini and get variables with paths, i.e.:
[XLS]
dir = D:\ExcelToSQL
workbook1 = workbook1.xls
workbook2 = workbook2.xls
workbook3 = workbook3.xls
[SQL]
user = root
password = password
host = localhost
database = database
port = 3306
ssl_ca =
ssl_verify_cert =
ssl_key =
ssl_cert =
encoding =
- script1 for changing values in XLS workbooks just functions with args and params
script2 for importing inMySQL DB, again just functions.
All variables come fromconfig.ini
Main problem when I debug my service. It can't read config.ini:
Error 0xC0000003 - The instance's SvcRun() method failed
Traceback (most recent call last):
File "C:Pythonlibsite-packageswin32libwin32serviceutil.py", line 839, in SvcRun
self.SvcDoRun()
File "D:rs_alIdeaProjectsExcelToSQLPyXLSQLservice.py", line 31, in SvcDoRun
self.main()
File "D:rs_alIdeaProjectsExcelToSQLPyXLSQLservice.py", line 37, in main
app()
File "D:rs_alIdeaProjectsExcelToSQLPyXLSQLpyxlsql.py", line 14, in app
path = config.get ("XLS", "dir")
File "C:Pythonlibconfigparser.py", line 780, in get
d = self._unify_values(section, vars)
File "C:Pythonlibconfigparser.py", line 1146, in _unify_values
raise NoSectionError(section) from None
configparser.NoSectionError: No section: 'XLS'
(null): (null)
I know where is an issue:
in main.py:print(sys.argv[0])
outputC:Pythonlibsite-packageswin32PythonService.exe
Is it possible to run the service as I want? Because now it is looking for ini file in C:Pythonlibsite-packageswin32PythonService.exe.
python service
I have a problem running my script as a service.
I don't understand what to do with paths.
What I have:
main.py (main code) service.py (template to install and run main.py
/ |
subdir/ subdir/ config.ini
script1.py script2.py
What in main.py:
1. I read config.ini and get variables with paths, i.e.:
[XLS]
dir = D:\ExcelToSQL
workbook1 = workbook1.xls
workbook2 = workbook2.xls
workbook3 = workbook3.xls
[SQL]
user = root
password = password
host = localhost
database = database
port = 3306
ssl_ca =
ssl_verify_cert =
ssl_key =
ssl_cert =
encoding =
- script1 for changing values in XLS workbooks just functions with args and params
script2 for importing inMySQL DB, again just functions.
All variables come fromconfig.ini
Main problem when I debug my service. It can't read config.ini:
Error 0xC0000003 - The instance's SvcRun() method failed
Traceback (most recent call last):
File "C:Pythonlibsite-packageswin32libwin32serviceutil.py", line 839, in SvcRun
self.SvcDoRun()
File "D:rs_alIdeaProjectsExcelToSQLPyXLSQLservice.py", line 31, in SvcDoRun
self.main()
File "D:rs_alIdeaProjectsExcelToSQLPyXLSQLservice.py", line 37, in main
app()
File "D:rs_alIdeaProjectsExcelToSQLPyXLSQLpyxlsql.py", line 14, in app
path = config.get ("XLS", "dir")
File "C:Pythonlibconfigparser.py", line 780, in get
d = self._unify_values(section, vars)
File "C:Pythonlibconfigparser.py", line 1146, in _unify_values
raise NoSectionError(section) from None
configparser.NoSectionError: No section: 'XLS'
(null): (null)
I know where is an issue:
in main.py:print(sys.argv[0])
outputC:Pythonlibsite-packageswin32PythonService.exe
Is it possible to run the service as I want? Because now it is looking for ini file in C:Pythonlibsite-packageswin32PythonService.exe.
python service
python service
edited Nov 9 at 8:37
Vineeth Sai
2,28441023
2,28441023
asked Nov 9 at 8:33
Rostislav Aleev
215
215
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53222233%2fpython-3-script-as-windows-service%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown