Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 98792

how do you fix the executable error with chromedriver Windows >>> in a transition to Ubuntu?

$
0
0

My goal is to execute a script i've used previously on windows, transitioned to chromedriver and there's this error:

Blockquote selenium.common.exceptions.WebDriverException: >> Message: 'chromedriver' executable needs to be in the PATH.

the windows exe file is in the PATH and works with windows. I've replaced that chromedriver with an up to date version of Linux chromedriver, have installed chrome web browser to the default directory. it seems to not recognize that the file is there and in the code it's not specified that it's a .exe it's looking for.

Here is the code

import scrapy
from ..items import AuctionscrapingItem
from selenium.webdriver.support.ui import 
WebDriverWait
from selenium.webdriver.support import 
expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.common.exceptions import 
TimeoutException
from selenium.common.exceptions import 
NoSuchElementException
from scrapy.crawler import CrawlerProcess
import time
import re
from twisted.internet import reactor, defer
from scrapy.crawler import CrawlerRunner
from scrapy.utils.log import configure_logging
from scrapy.settings import Settings
from auctionscraping import settings as my_settings
import mysql.connector
from datetime import datetime

class AuctionInt(scrapy.Spider):
    name = 'auction'
    start_urls = ['https://www.websitefunfirst.com/']


    def __init__(self):
        self.driver = webdriver.Chrome('/opt/lampp/htdocs/scrapy/chromedriver')
        self.driver.maximize_window()
        self.conn = mysql.connector.connect(
            host= 'localhost',
            user= 'root',
            passwd= '',
            database= 'auction'
        )

        self.curr = self.conn.cursor(buffered=True)
        self.curr.execute("""create table IF NOT EXISTS auction_tb(
            id int,
            web_name text,
            website text,
            name text,
            start text,
            end text,
            locations text,
            location_link text,
            remaining_time text,
            current_bid text,
            viewer text,
            premium text,
            image_urls text,
            bid text,
            starting_bid text,
            description text
        )""")
        self.curr.execute("""create table IF NOT EXISTS bid_history(
            id int NOT NULL,
            name varchar(50),
            bidder varchar(20) NOT NULL,
            bid_amount text,
            PRIMARY KEY (id,name,bidder)
        )""")
        try:
            self.curr.execute("""select id from auction_tb order by id desc limit 1""")
            last_id = self.curr.fetchone()
            self.id_no = last_id[0]
        except:
            self.id_no = 0
        f = open("/opt/lampp/htdocs/scrapy/result.txt", "w")
        f.write("scraping")
        f.close()
        self.clear_ended_item() 
         '''

in the code i've changed the driver directory to match ubuntu (change xampp to lampp and the directories prior) and i've added a placeholder for the website scraping. This part of the script and the whole script runs on windows perfectly. things i've tried:

  1. replacing the .exe file with the equivalent linux file.
  2. loading wine of the computer to execute the .exe when it's called. some things about that... after installing wine i right clicked the executable to open it with wine and wine was not an available option and there was no availability to search the computer for it.
  3. I have seen and tried the linux server options from here How to implement chromedriver in selenium in Linux platform
  4. scrolling down 3/4 down this page they've coded in Javascript something that apparently works for java.. here i'm unsure how to edit my python code in a similar way.https://tecadmin.net/setup-selenium-chromedriver-on-ubuntu/
  5. I change the pathing and do research but mostly i think the problem here is that i don't know how to change my code to make it work for linux.

Viewing all articles
Browse latest Browse all 98792

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>