WinError2 не удается найти указанный файл
Пытаюсь запустить несколько скриптов с помощью subprocess, но выбивает ошибку, в чем может быть проблема?
Вот код программы:
import os
from subprocess import call
from subprocess import Popen
import subprocess
from subprocess import sys
try:
subprocess.call(['C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\python.exe','C:/Users/К.Бояр (Второй)/source/repos/Rozetka_Parcer/Rozetka_Parcer/Rozetka_Parcer.py'])
except Exception as e:
print ('Process failed',e)
try:
subprocess.call(['C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\python.exe','C:/Users/К.Бояр (Второй)/source/repos/ALLOParcer/ALLOParcer/ALLOParcer.py'])
except Exception as e:
print ('Process failed',e)
Traceback:
Traceback (most recent call last):
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
stdin=PIPE)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\subprocess.py", line 800, in __init__
restore_signals, start_new_session)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\subprocess.py", line 1207, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] Не удается найти указанный файл
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/К.Бояр (Второй)/source/repos/ALLOParcer/ALLOParcer/ALLOParcer.py", line 81, in <module>
items = parse(url)
File "C:/Users/К.Бояр (Второй)/source/repos/ALLOParcer/ALLOParcer/ALLOParcer.py", line 32, in parse
driver = webdriver.Firefox(options=options)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 164, in __init__
self.service.start()
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\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.
Путь верный, смотрел через
import sys
print(sys.executable)
Ответы (1 шт):
Автор решения: Константин Николаевич Бояр II
→ Ссылка
Решение было довольно простое, спасибо за это Эникейщику, нужно было перед ссылкой на python.exe добавить r
Примерно вот так:
try:
subprocess.call([r'C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\python.exe','C:/Users/К.Бояр (Второй)/source/repos/Rozetka_Parcer/Rozetka_Parcer/Rozetka_Parcer.py'])
except Exception as e:
print ('Process failed',e)