I'm trying to setup Selenium with Python and Eclipse on my home computer but I keep getting the following 2 trace back errors. I know part of it is that the "geckodriver.exe" file is not in the correct path but I don't know where to move it to so its correct and what the "FileNotFoundError: [WinError 2] The system cannot find the file specified" error refers to.
Program:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
user_name = "123#gmail.com"
password = "Password123"
driver = webdriver.Firefox()
driver.get("https://www.facebook.com")
element = driver.find_element_by_id("email")
element.send_keys(user_name)
element = driver.find_element_by_id("pass")
element.send_keys(password)
element.send_keys(Keys.RETURN)
element.close()
Console Error Msg:
Traceback (most recent call last):
File "C:\Users\Owner\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "C:\Users\Owner\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 947, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,<br />
File "C:\Users\Owner\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1416, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Owner\eclipse-workspace\PyDev1\PyDevPackage\PyDevModule.py", line 10, in <module>
driver = webdriver.Firefox()
File "C:\Users\Owner\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 164, in __init__
self.service.start()
File "C:\Users\Owner\AppData\Local\Programs\Python\Python39\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
Related
I tried to use python to call the “ansys-fluent-core” package, but after I ran it, the following error occurred. I don't know where the problem is. Can you help me and give me some suggestions.
my code:
import ansys.fluent.core as pyfluent
session = pyfluent.launch_fluent(precision="double", processor_count=4, show_gui=True,
mode="solver")
error:
E:\HB-software\Anaconda\anaconda\envs\py38\python.exe C:\Users\86139\PycharmProjects\pythonProject2\main.py
Traceback (most recent call last):
File "C:\Users\86139\PycharmProjects\pythonProject2\main.py", line 2, in <module>
session = pyfluent.launch_fluent(precision="double", processor_count=4, show_gui=True,mode="solver")
File "E:\HB-software\Anaconda\anaconda\envs\py38\lib\site-
packages\ansys\fluent\core\launcher\launcher.py", line 560, in launch_fluent
subprocess.Popen(launch_string, **kwargs)
File "E:\HB-software\Anaconda\anaconda\envs\py38\lib\subprocess.py", line 858, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "E:\HB-software\Anaconda\anaconda\envs\py38\lib\subprocess.py", line 1311, in
_execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the specified file.
Process finished with exit code 1
I wanted to create a Minecraft Launcher using Python today, but the game cannot be started.
My Code:
import minecraft_launcher_lib
import subprocess
minecraft_directory = "C:\\Users\\Mert KAPLANDAR\\AppData\\Roaming\\.minecraft"
options = minecraft_launcher_lib.utils.generate_test_options()
minecraft_command = minecraft_launcher_lib.command.get_minecraft_command("1.8.9", minecraft_directory, options)
subprocess.call(minecraft_command)
Error:
Traceback (most recent call last):
File "C:\Users\Mert KAPLANDAR\Desktop\launcher.py", line 10, in <module>
subprocess.call(str(minecraft_command))
File "C:\Users\Mert KAPLANDAR\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 349, in call
with Popen(*popenargs, **kwargs) as p:
File "C:\Users\Mert KAPLANDAR\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\Mert KAPLANDAR\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1420, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] Sistem belirtilen dosyayı bulamıyor
#Mert Kaplander, I would believe the error might be because you don't have that version of Minecraft installed. You can check with the following method:
minecraft_launcher_lib.utils.get_installed_versions(minecraft_dir)
example:
import subprocess
import minecraft_launcher_lib
from colorama import Fore, init
for version in minecraft_launcher_lib.utils.get_installed_versions(minecraft_dir):
print(Fore.GREEN+ f"{version}")
Other than that, your code is an exact copy from the documentation. So I don't see an other error.
I have python3 code, that works in Windows OS, but doesn't on raspberry pi4
Maybe anybody can help?
import time
import os
from webbot import Browser
web = Browser()
web.go_to('https://xxxxxxx')
#time.sleep(1)
web.type('cccccccc', into = 'email')
#time.sleep(1)
web.type('dddddddd', into = 'password', id='edit-pass')
web.click('submit', id='edit-submit')
In windows OS this works, but on Raspberry Pi OS it is returning answer
%Run eso.py Traceback (most recent call last): File "/home/pi/ESO/eso.py", line 5, in <module>
web = Browser() File "/usr/local/lib/python3.7/dist-packages/webbot/webbot.py", line 66, in
__init__
os.chmod(driverpath, 0o755) PermissionError: [Errno 1] Operation not permitted: '/usr/local/lib/python3.7/dist-packages/webbot/drivers/chrome_linux'
Any things?
After trying to make changes by answer, i get this:
pi#raspberrypi:~/ESO $ sudo python3 eso.py
Traceback (most recent call last):
File "eso.py", line 5, in <module>
web = Browser()
File "/usr/local/lib/python3.7/dist-packages/webbot/webbot.py", line 68, in __init__
self.driver = webdriver.Chrome(executable_path=driverpath, options=options)
File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
self.service.start()
File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/common/service.py", line 76, in start
stdin=PIPE)
File "/usr/lib/python3.7/subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.7/subprocess.py", line 1522, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: '/usr/local/lib/python3.7/dist-packages/webbot/drivers/chrome_linux'
u may try using a module called webbrowser or
as the error says its not getting the right permition so do this :
open terminal
type " cd (where u have stored ur file)"
type " sudo python3 (filename).py"
thats it
Solved by changing method from webbot to selenium
I am trying to build a simple dataset for speech recognition using aneas, following the instruction here. However I'm stuck at the forced alignment, here is my code
from aeneas.executetask import ExecuteTask
from aeneas.task import Task
import os
import numpy
config_string = "task_language=eng | is_text_type=plain | os_task_file_format=json"
task = Task (config_string=config_string)
task.audio_file_path_absolute = "D:/documents/AI/open_door.mp3"
task.text_file_path_absolute = "D:/documents/AI/open_door.txt"
task.sync_map_file_path_absolute = "D:/documents/AI/syncmap.json"
ExecuteTask(task).execute()
task.output_sync_map_file()
Which gives the following error:
Traceback (most recent call last):
File "C:\Users\ACER\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aeneas\ffprobewrapper.py", line 222, in read_properties
proc = subprocess.Popen(
File "C:\Users\ACER\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\ACER\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 1307, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\ACER\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aeneas\audiofile.py", line 357, in read_properties
properties = FFPROBEWrapper(
File "C:\Users\ACER\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aeneas\ffprobewrapper.py", line 233, in read_properties
self.log_exc(u"Unable to call the '%s' ffprobe executable" % (self.rconf[RuntimeConfiguration.FFPROBE_PATH]), exc, True, FFPROBEPathError)
File "C:\Users\ACER\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aeneas\logger.py", line 351, in log_exc
raise raise_type(raise_message)
aeneas.ffprobewrapper.FFPROBEPathError: Unable to call the 'ffprobe' ffprobe executable : [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\documents\AI\forced_alignment.py", line 9, in <module>
task.audio_file_path_absolute = "D:/documents/AI/open_door.mp3"
File "C:\Users\ACER\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aeneas\task.py", line 120, in audio_file_path_absolute
self._populate_audio_file()
File "C:\Users\ACER\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aeneas\task.py", line 241, in _populate_audio_file
self.audio_file.read_properties()
File "C:\Users\ACER\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aeneas\audiofile.py", line 363, in read_properties
self.log_exc(u"Unable to call ffprobe executable", None, True, AudioFileProbeError)
File "C:\Users\ACER\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aeneas\logger.py", line 351, in log_exc
raise raise_type(raise_message)
aeneas.audiofile.AudioFileProbeError: Unable to call ffprobe executable
[Finished in 0.4s]
Intuitively, I think it is because of the file paths, but changing it doesn't seem to work. I have never worked with python before so show me where I did wrong. Thank you.
I'm pretty sure it's because ffprobe isn't in your system's environmental variables.
Have you tried running python -m aeneas.diagnostics and is ffprobe in your path? Look into adding programs to your Path/system environment variables.
from selenium import webdriver
driver = webdriver.Chrome()
driver = webdriver.Chrome(
r'C:\Users\New User prof\Downloads\chromedriver_win32.zip\chromedriver.exe')
driver.get(
"https://www.google.com/webmasters/tools/url-removal?hl=en&siteUrl=https://www.greatbuyz.com/&mesd=AB9YKzIL4DBt4yX8SVayjC2kUq8yeXctK_u2WGH4KlESTcjXkcOsdBvVP7TnX4S4bBF4PADFQzZAxIqcxMiVerW67kTw-UGIWjHVftlzX5DNcJjm3Uz5wBpWxkDYY7IIFlVMdiEvTsAG_GwgA_DqO7Exg5w80HGHX_lk4okr-Ay7vrCG63zKVLrMGmyNMUPGEESjX2rJF-Xx&authuser=2")
driver.find_element_by_xpath(
"//button[#class='goog-inline-block jfk-button jfk-button-standard']").click()
Error:
Traceback (most recent call last):
File "/root/pythonnk/my_env/lib64/python3.6/site-packages/selenium/webdriver/common/service.py", line 76, in start
stdin=PIPE)
File "/usr/lib64/python3.6/subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "/usr/lib64/python3.6/subprocess.py", line 1344, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver': 'chromedriver'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "bot.py", line 4, in <module>
driver = webdriver.Chrome()
File "/root/pythonnk/my_env/lib64/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
self.service.start()
File "/root/pythonnk/my_env/lib64/python3.6/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: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
I am not cent percent sure this is the problem. If there are spaces in your path, sometimes the path is not recognized in windows. You can try adding additional double quotes around your path like this.
driver = webdriver.Chrome(
r'"C:\Users\New User prof\Downloads\chromedriver_win32.zip\chromedriver.exe"')
I can't confirm weather it needs to be extracted. I am not using windows right now so can't test.
Make sure you extract the zip file before you use it and provide that extracted file path.
Use forward slash while giving the path.
Try the code below
from selenium import webdriver
driver = webdriver.Chrome(
'C:/Users/New User prof/Downloads/chromedriver_win32.zip/chromedriver.exe')
driver.get("URL")
driver.find_element_by_xpath("//button[#class='goog-inline-block jfk-button jfk- button-standard']").click()