I've recently started devling into cx_freeze and creating .exe files for other people to use.
The script is fairly simple: It uses Selenium to scrape javascript-sensitive content on a website, and gives the user a notification when it finds a matching href + copies the link to the clipboard:
The main code in main.py:
from bs4 import BeautifulSoup
from selenium import webdriver
import time
import pyperclip
def check():
browser.get(browser.current_url)
page_html = browser.page_source.encode('utf8')
soup = BeautifulSoup(page_html, "lxml")
complete_list = soup.find_all('a', href=True)
for a in complete_list:
if LINK_TO_FIND in a['href']:
pyperclip.copy(a['href'])
while True:
beep()
browser = webdriver.Chrome(executable_path=path_to_chromedriver)
browser.get(URL_TO_CHECK)
while True:
check()
time.sleep(5)
The cx_freeze code in setup.py:
import sys
from cx_Freeze import setup, Executable
build_exe_options = {"packages": ["os", "lxml", "gzip"], "excludes": ["tkinter"]}
base = 'Console'
setup( name = "web_scraper",
version = "0.1",
description = "desc",
options = {"build_exe": build_exe_options},
executables = [Executable("main.py", base=base)])
Until yesterday, this script was running fine on both mine and other machines. But starting yesterday, this error has started to pop up whenever someone else runs the newly built .exe:s. (New ones still works fine for me, old versions still work on other machines):
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\selenium\webdriver\chrome\service.py", line 68, in start
File "C:\Python34\lib\subprocess.py", line 859, in __init__
File "C:\Python34\lib\subprocess.py", line 1112, in _execute_child
PermissionError: [WinError 5] Access is denied
During handling of the above exception, another exception occured:
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27, in (module)
File "main.py", line 48, in (module)
File "C:\Python34\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 62, in __init__
File "C:\Python34\lib\site-packages\selenium\webdriver\chrome\service.py", line 80, in start
selenium.common.exceptions.WebDriverException: Message: 'exe.win32-3.4' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home
Some things I've tried:
python setup.py build
Alright, so after about 4 hours of troubleshooting I realized that the path_to_chromedriver
was missing \chromedriver.exe
at the end for the version I was sending over, but was correct for the verison I was using locally. Shoot me.