4

I am having problems getting py2app to work with my python webscraper program that uses Selenium.

I know that I have to include selenium in my packages, but nothing is working. I can't see an error message because the .app won't open.

The imports in my python fie look like this.

#! python3
import urllib
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.common.by import By
import pdb

And my setup.py file looks like this

    """
This is a setup.py script generated by py2applet

Usage:
    python setup.py py2app
"""

from setuptools import setup

APP = ['highlights.py']
DATA_FILES = ['doi_list.txt']
OPTIONS = {'argv_emulation': True
           'packages': ['urllib', 'pdb', 'selenium'] 
}

setup(
    app=APP,
    data_files=DATA_FILES,
    options={'py2app': OPTIONS},
    setup_requires=['py2app'],
)

I followed Marina Mele's py2app tutorial but she just brushes over including packages, and I have no idea how to do this. I'm new to programming.

Do you know what I am doing wrong?

moglido
  • 158
  • 2
  • 13

2 Answers2

1

Maybe you could try this:

driver_path = 'xxxx/chromedriver'  # path of your chromedriver
DATA_FILES = ['doi_list.txt', driver_path]

It works for me.

And make sure app/Contents/Resources/chromedriver has the permissions to execute.

Right click your app, select "show Package Contents".

anothernode
  • 5,100
  • 13
  • 43
  • 62
LIli Shi
  • 11
  • 2
0

Instead of 'packages', try using 'includes'. (Works in py2app v0.13)

OPTIONS = {
        'argv_emulation': True,
        'includes': ['httplib2', 'requests', 'selenium']
        }

PS: make sure to include commas to separate list entries

Dan A.
  • 1
  • 1