SQL server agent geeft foutmelding bij Job run Python script

Status
Niet open voor verdere reacties.

VandeGoede1975

Nieuwe gebruiker
Lid geworden
8 aug 2021
Berichten
4
Goedemorgen allemaal,

Toen ik 6 jaar geleden met Access voor het eerst te maken kreeg heeft dit forum mij enorm op weg geholpen.
Inmiddels kom ik bijna overal wel zelf uit, alleen loop ik nu tegen een probleempje aan waarvan ik het heel fijn zou vinden als iemand even mee zou kunnen denken :)!

Ik heb een simpel Python script gemaakt dat automatisch naar een website gaat en daar een Excel bestand download.
Dit heb ik verder in een SSIS package (met wat andere data bewerking) verwerkt.
Via Visual Studio werkt de package.
Vervolgens wilde ik via SQL agent een job aanmaken, waarbij de package om de zoveel tijd automatisch loopt.
Echter krijg ik foutmelding bij het runnen van de job.
Wat ik heb gemerkt is dat het aan het python script ligt dat de data automatisch ophaalt via het internet.
Een ander python script dat de data van Excel naar CSV omzet werkt namelijk wel gewoon via de SQL agent.
Ik zit al een tijdje te zoeken maar kom niet verder met dit probleem
Zou iemand mij hier wellicht kunnen helpen, mijn dank is groot!

Het python script ziet er alsvolgt uit:
Code:
import sys
from selenium import webdriver
from selenium.webdriver.support.select import Select
from selenium.webdriver.common.keys import Keys
import pandas as pd
from bs4 import BeautifulSoup


option = webdriver.ChromeOptions()
prefs = {"download.default_directory" : "C:\\DownloadFolder\\"}
option.add_experimental_option("prefs",prefs)
option.add_argument("--start-maximized");
chromedriver = "C:\Script\chromedriver.exe"
driver = webdriver.Chrome(executable_path=chromedriver, options=option)


BASE_URl = "https://www.mywebsite.com"
driver.get(BASE_URl)
time.sleep(3)

link2 = driver.find_element_by_xpath("mypath").text; 

link = driver.find_element_by_link_text(link2)
link.click()

time.sleep(10)

driver.quit()
sys.exit(0)

Foutmelding SQL Agent:

Executed as user: DESKTOP-3SDAFD\4664656. Microsoft (R) SQL Server Execute Package Utility Version 15.0.2000.5 for 32-bit Copyright (C) 2019 Microsoft. All rights reserved. Code: 0xC0029151 Source: Transform_PD Execute Process Task Description: In Executing "C:\Python\Python392\python.exe" "myscript.py" at "C:\script", The process exit code was "1" while the expected was "0". End Error DTExec: The package execution returned DTSER_FAILURE (1). Started: 16:50:28 Finished: 16:50:41 Elapsed: 12.718 seconds. The package execution failed. The step failed.

Alvast harstikke bedankt voor de moeite en het meedenken!
Gr
 
Heb je al op de error-code gezocht?
 
Ik had nog niet op de specifieke foutcode gezocht, nadat ik dat nu heb gezien gaat het wel richting de uitvoeringsrechten.
Ik heb al een proxy account opgezet, volgens mij zouden de instellingen hiervan goed moeten staan.
Dacht het op te lossen door bij mijn proxy account bij "Active to the following subsystems": "Operating System (CmDExec) aan te vinken, alleen dat werkt ook niet. Het gekke is dat als ik een simple py script als "print("hello world") wil draaien dat wel werkt.

Heb het geprobeerd via PowerShell het script uit te voeren via SQL agent, daarbij krijg ik devolgende melding:

Message
Executed as user: stop the script: A job step received an error at line 2 in a PowerShell script. The corresponding line is 'py Myscript.py'. Correct the script and reschedule the job. The error information returned by PowerShell is: 'Traceback (most recent call last): ' A job step received an error at line 2 in a PowerShell script. The corresponding line is 'py Myscript.py'. Correct the script and reschedule the job. The error information returned by PowerShell is: ' File "C:\Myscript.py", line 26, in <module> ' A job step received an error at line 2 in a PowerShell script. The corresponding line is 'py Myscript.py'. Correct the script and reschedule the job. The error information returned by PowerShell is: ' driver = webdriver.Chrome(executable_path=chromedriver, options=option) ' A job step received an error at line 2 in a PowerShell script. The corresponding line is 'py Myscript.py'. Correct the script and reschedule the job. The error information returned by PowerShell is: ' File "C:\Python\Python392\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 76, in __init__ ' A job step received an error at line 2 in a PowerShell script. The corresponding line is 'py Myscript.py'. Correct the script and reschedule the job. The error information returned by PowerShell is: ' RemoteWebDriver.__init__( ' A job step received an error at line 2 in a PowerShell script. The corresponding line is 'py Myscript.py'. Correct the script and reschedule the job. The error information returned by PowerShell is: ' File "C:\Python\Python392\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__ ' A job step received an error at line 2 in a PowerShell script. The corresponding line is 'py Myscript.py'. Correct the script and reschedule the job. The error information returned by PowerShell is: ' self.start_session(capabilities, browser_profile) ' A job step received an error at line 2 in a PowerShell script. The corresponding line is 'py Myscript.py'. Correct the script and reschedule the job. The error information returned by PowerShell is: ' File "C:\Python\Python392\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session ' A job step received an error at line 2 in a PowerShell script. The corresponding line is 'py Myscript.py'. Correct the script and reschedule the job. The error information returned by PowerShell is: ' response = self.execute(Command.NEW_SESSION, parameters) ' A job step received an error at line 2 in a PowerShell script. The corresponding line is 'py Myscript.py'. Correct the script and reschedule the job. The error information returned by PowerShell is: ' File "C:\Python\Python392\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute ' A job step received an error at line 2 in a PowerShell script. The corresponding line is 'py Myscript.py'. Correct the script and reschedule the job. The error information returned by PowerShell is: ' self.error_handler.check_response(response) ' A job step received an error at line 2 in a PowerShell script. The corresponding line is 'py Myscript.py'. Correct the script and reschedule the job. The error information returned by PowerShell is: ' File "C:\Python\Python392\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response ' A job step received an error at line 2 in a PowerShell script. The corresponding line is 'py Myscript.py'. Correct the script and reschedule the job. The error information returned by PowerShell is: ' raise exception_class(message, screen, stacktrace) ' A job step received an error at line 2 in a PowerShell script. The corresponding line is 'py Myscript.py'. Correct the script a... Process Exit Code 0. The step succeeded.

Ik heb zelf het idee dat hij moeite heeft om de chromedriver uit te voeren..
 
Laatst bewerkt:
Probleem waar ik dus nu tegen aanloop is dat die het de ene keer wel en de andere keer niet doet me SQL agent, heel vaag :rolleyes:
Lijkt mij iets te zijn dat hij de processen die het script heeft gebruikt niet goed afsluit na gebruik.
Nu blijft die bijvoorbeeld weer in een eeuwige loop zitten, programmatje duur ongeveer 30 seconden, is nu alweer 10min bezig...
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan