Platform
AWS
Describe your issue as much as you can
** What happened?**
It turns out that when I run these instructions in my command line in AWS Ubuntu: /usr/bin/python3.11 && /home/bitnami/spacy_venv/bin/python3.11 /home/bitnami/htdocs/android_app_selenium.py _2Qqa4ri7KQ, it calls a file where I have Selenium, which accesses a webpage and successfully downloads a multimedia file from that page. This works excellent in the CLI!
But when I need to do the same from a PHP file that executes my Python file, I get this error:
Error
Selenium test separated from obtainingyoutube_news
return_python_videoId: Starting Selenium test video_id: _2Qqa4ri7KQ video_id_yblink: https://www.youtube.com/watch?v=_2Qqa4ri7KQ Traceback (most recent call last): File "/home/bitnami/spacy_venv/lib/python3.11/site-packages/urllib3/connectionpool.py", line 534, in _make_request response = conn.getresponse() ^^^^^^^^^^^^^^^^^^ File "/home/bitnami/spacy_venv/lib/python3.11/site-packages/urllib3/connection.py", line 571, in getresponse httplib_response = super().getresponse() ^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/http/client.py", line 1394, in getresponse response.begin() File "/usr/lib/python3.11/http/client.py", line 323, in begin version, status, reason = self._read_status() ^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/http/client.py", line 284, in _read_status line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/socket.py", line 706, in readinto return self._sock.recv_into(b) ^^^^^^^^^^^^^^^^^^^^^^^ TimeoutError: timed out The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/bitnami/htdocs/android_app_selenium.py", line 79, in show_time() File "/home/bitnami/htdocs/android_app_selenium.py", line 31, in show_time driver = webdriver.Firefox(options=options) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/bitnami/spacy_venv/lib/python3.11/site-packages/selenium/webdriver/firefox/webdriver.py", line 69, in init super().init(command_executor=executor, options=self.options) File "/home/bitnami/spacy_venv/lib/python3.11/site-packages/selenium/webdriver/common/webdriver.py", line 25, in init super().init(*args, **kwargs) File "/home/bitnami/spacy_venv/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 276, in init self.start_session(capabilities) File "/home/bitnami/spacy_venv/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 372, in start_session response = self.execute(Command.NEW_SESSION, caps)["value"] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/bitnami/spacy_venv/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 465, in execute response = cast(RemoteConnection, self.command_executor).execute(driver_command, params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/bitnami/spacy_venv/lib/python3.11/site-packages/selenium/webdriver/remote/remote_connection.py", line 407, in execute return self._request(command_info[0], url, body=data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/bitnami/spacy_venv/lib/python3.11/site-packages/selenium/webdriver/remote/remote_connection.py", line 431, in _request response = self._conn.request(method, url, body=body, headers=headers, timeout=self._client_config.timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/bitnami/spacy_venv/lib/python3.11/site-packages/urllib3/_request_methods.py", line 143, in request return self.request_encode_body( ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/bitnami/spacy_venv/lib/python3.11/site-packages/urllib3/_request_methods.py", line 278, in request_encode_body return self.urlopen(method, url, **extra_kw) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/bitnami/space_venv/lib/python3.11/site-packages/urllib3/poolmanager.py", line 457, in urlopen response = conn.urlopen(method, u.request_uri, **kw) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/bitnami/spacy_venv/lib/python3.11/site-packages/urllib3/connectionpool.py", line 841, in urlopen retries = retries.increment( ^^^^^^^^^^^^^^^^^^ File "/home/bitnami/spacey_venv/lib/python3.11/site-packages/urllib3/util/retry.py", line 490, in increment raise reraise(type(error), error, _stacktrace) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/bitnami/spacy_venv/lib/python3.11/site-packages/urllib3/util/util.py", line 39, in reraise raise File value "/home/bitnami/space_venv/lib/python3.11/site-packages/urllib3/connectionpool.py", line 787, in urlopen response = self._make_request( ^^^^^^^^^^^^^^^^^^^ File "/home/bitnami/spacey_venv/lib/python3.11/site-packages/urllib3/connectionpool.py", line 536, in _make_request self._raise_timeout(err=e, url=url, timeout_value=read_timeout) File "/home/bitnami/spacy_venv/lib/python3.11/site-packages/urllib3/connectionpool.py", line 367, in _raise_timeout raise ReadTimeoutError( urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='localhost', port=53487): Read timed out. (read timeout=120)
Could it be something related to bitnami and daemon user permissions?
Reproducible Code
Python Code:
import sys
import os
from selenium import webdriver
from selenium.webdriver.common.by import By
import time
from selenium.webdriver.firefox.options import Options
os.environ["SE_CACHE_PATH"] = "/home/bitnami/htdocs/uploads/"
def show_time():
#strTo = sys.argv[1]
#print ("strTo: ", strTo)
#print("This is the name of the program:", sys.argv[0])
#print("Number of elements including the name of the program:", len(sys.argv))
#print("Number of elements excluding the name of the program:", len(sys.argv) - 1)
#print("Argument List:", str(sys.argv))
textofinal = "Hola android_app_selenium"
print("Iniciando prueba Selenium")
print("video_id: ", sys.argv[1])
print("video_id_yblink: ", "https://www.youtube.com/watch?v=" + sys.argv[1])
options = Options()
options.add_argument("--headless")
driver = webdriver.Firefox(options=options)
driver.get("https://media.ytmp3.gg/mx/youtube-to-wav-converter")
print(driver.title)
search_box = driver.find_element(By.ID, "videoUrl")
print("search_box: ", search_box)
search_box.clear()
#search_box.send_keys("https://www.youtube.com/watch?v=59hk11-nDSw")
search_box.send_keys("https://www.youtube.com/watch?v=" + sys.argv[1])
#time.sleep(2)
check_box = driver.find_element(By.XPATH, '//*[@id="copyright-consent-checkbox"]')
print("check_box: ", check_box)
check_box.click()
#time.sleep(2)
#button_download = driver.find_element(By.ID, "submit-button")
#button_download = driver.find_element(By.XPATH, '//*[@id="submit-button"]')
#print("button_download: ", button_download)
#button_download.click()
time.sleep(12)
#button_download2 = driver.find_element(By.ID, "download-btn")
button_download2 = driver.find_element(By.XPATH, '//*[@id="download-btn"]')
print("button_download2: ", button_download2)
button_download2.click()
#driver.quit()
print("Terminando prueba Selenium")
return textofinal
if __name__ == '__main__':
#print(show_time())
show_time()
PHP Code:
<?php
ini_set('display_errors', 1);
echo 'Selenium test separada de obtainingyoutube_news'; echo "<br>";
$return_python_videoId = shell_exec('/usr/bin/python3.11 && /home/bitnami/spacy_venv/bin/python3.11 /home/bitnami/htdocs/android_app_selenium.py _2Qqa4ri7KQ 2>&1');
echo "return_python_videoId: ". $return_python_videoId; echo "<br>";
?>
Platform
AWS
Describe your issue as much as you can
** What happened?**
It turns out that when I run these instructions in my command line in AWS Ubuntu: /usr/bin/python3.11 && /home/bitnami/spacy_venv/bin/python3.11 /home/bitnami/htdocs/android_app_selenium.py _2Qqa4ri7KQ, it calls a file where I have Selenium, which accesses a webpage and successfully downloads a multimedia file from that page. This works excellent in the CLI!
But when I need to do the same from a PHP file that executes my Python file, I get this error:
Error
Selenium test separated from obtainingyoutube_news
return_python_videoId: Starting Selenium test video_id: _2Qqa4ri7KQ video_id_yblink: https://www.youtube.com/watch?v=_2Qqa4ri7KQ Traceback (most recent call last): File "/home/bitnami/spacy_venv/lib/python3.11/site-packages/urllib3/connectionpool.py", line 534, in _make_request response = conn.getresponse() ^^^^^^^^^^^^^^^^^^ File "/home/bitnami/spacy_venv/lib/python3.11/site-packages/urllib3/connection.py", line 571, in getresponse httplib_response = super().getresponse() ^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/http/client.py", line 1394, in getresponse response.begin() File "/usr/lib/python3.11/http/client.py", line 323, in begin version, status, reason = self._read_status() ^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/http/client.py", line 284, in _read_status line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/socket.py", line 706, in readinto return self._sock.recv_into(b) ^^^^^^^^^^^^^^^^^^^^^^^ TimeoutError: timed out The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/bitnami/htdocs/android_app_selenium.py", line 79, in show_time() File "/home/bitnami/htdocs/android_app_selenium.py", line 31, in show_time driver = webdriver.Firefox(options=options) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/bitnami/spacy_venv/lib/python3.11/site-packages/selenium/webdriver/firefox/webdriver.py", line 69, in init super().init(command_executor=executor, options=self.options) File "/home/bitnami/spacy_venv/lib/python3.11/site-packages/selenium/webdriver/common/webdriver.py", line 25, in init super().init(*args, **kwargs) File "/home/bitnami/spacy_venv/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 276, in init self.start_session(capabilities) File "/home/bitnami/spacy_venv/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 372, in start_session response = self.execute(Command.NEW_SESSION, caps)["value"] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/bitnami/spacy_venv/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 465, in execute response = cast(RemoteConnection, self.command_executor).execute(driver_command, params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/bitnami/spacy_venv/lib/python3.11/site-packages/selenium/webdriver/remote/remote_connection.py", line 407, in execute return self._request(command_info[0], url, body=data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/bitnami/spacy_venv/lib/python3.11/site-packages/selenium/webdriver/remote/remote_connection.py", line 431, in _request response = self._conn.request(method, url, body=body, headers=headers, timeout=self._client_config.timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/bitnami/spacy_venv/lib/python3.11/site-packages/urllib3/_request_methods.py", line 143, in request return self.request_encode_body( ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/bitnami/spacy_venv/lib/python3.11/site-packages/urllib3/_request_methods.py", line 278, in request_encode_body return self.urlopen(method, url, **extra_kw) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/bitnami/space_venv/lib/python3.11/site-packages/urllib3/poolmanager.py", line 457, in urlopen response = conn.urlopen(method, u.request_uri, **kw) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/bitnami/spacy_venv/lib/python3.11/site-packages/urllib3/connectionpool.py", line 841, in urlopen retries = retries.increment( ^^^^^^^^^^^^^^^^^^ File "/home/bitnami/spacey_venv/lib/python3.11/site-packages/urllib3/util/retry.py", line 490, in increment raise reraise(type(error), error, _stacktrace) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/bitnami/spacy_venv/lib/python3.11/site-packages/urllib3/util/util.py", line 39, in reraise raise File value "/home/bitnami/space_venv/lib/python3.11/site-packages/urllib3/connectionpool.py", line 787, in urlopen response = self._make_request( ^^^^^^^^^^^^^^^^^^^ File "/home/bitnami/spacey_venv/lib/python3.11/site-packages/urllib3/connectionpool.py", line 536, in _make_request self._raise_timeout(err=e, url=url, timeout_value=read_timeout) File "/home/bitnami/spacy_venv/lib/python3.11/site-packages/urllib3/connectionpool.py", line 367, in _raise_timeout raise ReadTimeoutError( urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='localhost', port=53487): Read timed out. (read timeout=120)
Could it be something related to bitnami and daemon user permissions?
Reproducible Code
Python Code:
PHP Code: