[英]Setting up py2app to run selenium
我在讓py2app與使用Selenium的python webscraper程序一起使用時遇到問題。
我知道我必須在包裝中加入硒,但沒有任何效果。 我看不到錯誤消息,因為.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教程,但她只是仔細檢查了包含的軟件包,而且我不知道該怎么做。 我是編程新手。
你知道我在做什么錯嗎?
嘗試使用“ includes”代替“ packages”。 (適用於py2app v0.13)
OPTIONS = {
'argv_emulation': True,
'includes': ['httplib2', 'requests', 'selenium']
}
PS:確保使用逗號分隔列表條目
也許您可以嘗試以下方法:
driver_path = 'xxxx/chromedriver' # path of your chromedriver
DATA_FILES = ['doi_list.txt', driver_path]
這個對我有用。
並確保app/Contents/Resources/chromedriver
具有執行權限。
右鍵單擊您的應用,選擇“顯示包裝內容”。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.