当前,我的脚本在服务器cron中特定时间运行的时间表内运行正常。当前,我的脚本在服务器cron中特定时间运行的时间表内运行良好。
当我尝试在控制器内执行该方法时,就会出现问题,该方法基本上使用shell_exec()来执行python中的脚本,而这就是我对Laravel的处理。
当我从控制台或日程表中调用它时,它可以正常工作,但是当我调用该方法甚至是一个\Artisan::call('schedule:test');
时,它会返回相同的错误,表明未找到geckdriver。
The command "python C:/wamp64/www/MoneyGuard/pythonGuard/tesouro_direto/tesouro_direto_precos_taxa_titulo.py" failed.
Exit Code: 1(General error)
Working directory: C:\wamp64\www\MoneyGuard\public
Output:
================
[ {"inicio": "2018-06-30 11:04:23.830834"},
Error Output:
================
Traceback (most recent call last):
File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
stdin=PIPE)
File "C:\Program Files (x86)\Python36-32\lib\subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "C:\Program Files (x86)\Python36-32\lib\subprocess.py", line 997, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] O sistema não pode encontrar o arquivo especificado
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/wamp64/www/MoneyGuard/pythonGuard/tesouro_direto/tesouro_direto_precos_taxa_titulo.py", line 17, in <module>
firefox = webdriver.Firefox(firefox_options=opts)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 152, in __init__
self.service.start()
File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 83, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
当我在终端中运行它时:它运行完美:
λ php artisan schedule:teste
[ {"inicio": "2018-06-29 17:23:08.963534"},
{ "titulo": "Tesouro IPCA+ 2024", "vencimento": "2024-08-15 00:00:00", "taxa_rendimento": "5.62", "valor_minimo": "44.50", "preco_unitario": "2225.41" },
{ "titulo": "Tesouro IPCA+ 2035", "vencimento": "2035-05-15 00:00:00", "taxa_rendimento": "5.87", "valor_minimo": "35.72", "preco_unitario": "1190.74" },
{ "titulo": "Tesouro IPCA+ 2045", "vencimento": "2045-05-15 00:00:00", "taxa_rendimento": "5.87", "valor_minimo": "33.70", "preco_unitario": "674.18" },
{ "titulo": "Tesouro IPCA+ com Juros Semestrais 2026", "vencimento": "2026-08-15 00:00:00", "taxa_rendimento": "5.68", "valor_minimo": "32.40", "preco_unitario": "3240.59" },
{ "titulo": "Tesouro IPCA+ com Juros Semestrais 2035", "vencimento": "2035-05-15 00:00:00", "taxa_rendimento": "5.79", "valor_minimo": "32.04", "preco_unitario": "3204.72" },
{ "titulo": "Tesouro IPCA+ com Juros Semestrais 2050", "vencimento": "2050-08-15 00:00:00", "taxa_rendimento": "5.88", "valor_minimo": "32.36", "preco_unitario": "3236.30" },
{ "titulo": "Tesouro Prefixado 2021", "vencimento": "2021-01-01 00:00:00", "taxa_rendimento": "9.20", "valor_minimo": "32.09", "preco_unitario": "802.49" },
{ "titulo": "Tesouro Prefixado 2025", "vencimento": "2025-01-01 00:00:00", "taxa_rendimento": "11.44", "valor_minimo": "34.66", "preco_unitario": "495.21" },
{ "titulo": "Tesouro Selic 2023", "vencimento": "2023-03-01 00:00:00", "taxa_rendimento": "0.02", "valor_minimo": "95.72", "preco_unitario": "9572.17" },
{"fim": "2018-06-29 17:23:19.484442"} ]
Python脚本:tesouro_direto_precos_taxa_titulo.py
从我在控制器内运行命令时注意到的内容来看,它没有使用系统的路径。问题是为什么?
在此先感谢您的帮助。