我在让 py2app 与使用 Selenium 的 python webscraper 程序一起工作时遇到问题。
我知道我必须在我的包中包含 selenium,但没有任何效果。我看不到错误消息,因为 .app 无法打开。
我的 python fie 中的导入看起来像这样。
#! 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
我的 setup.py 文件看起来像这样
"""
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'],
)
我关注了 Marina Mele 的 py2app tutorial但她只是刷了一遍,包括包裹,我不知道该怎么做。我是编程新手。
你知道我做错了什么吗?
最佳答案
也许你可以试试这个:
driver_path = 'xxxx/chromedriver' # path of your chromedriver
DATA_FILES = ['doi_list.txt', driver_path]
这个对我有用。
并确保
app/Contents/Resources/chromedriver
有执行权限。右键单击您的应用程序,选择“显示包内容”。
关于python - 设置 py2app 以运行 selenium,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35510683/