首页 > 解决方案 > 运行 python selenium 代码时在 Heroku cli 中显示类型错误

问题描述

我正在尝试在 Heroku 中运行 selenium 脚本以打开多个 URL 并从那里抓取数据。它在我当地运行良好。但是当我尝试从 Heroku 运行我的脚本时,我得到了以下错误。我正在使用 Heroku-CLI 仅运行一个文件。[使用的命令:python“folder_name/filename.py”]:

'''

Traceback (most recent call last):
File "script/case.py", line 72, in <module>
df_cases=get_cases(driver=initialize_driver())
File "script/case.py", line 19, in initialize_driver
driver=webdriver.Chrome(executable_path=os.environ.get("CHROME_DRIVER_PATH"),options=chrome_options)
  File "/app/.heroku/python/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
self.service.start()
  File "/app/.heroku/python/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 72, in start
self.process = subprocess.Popen(cmd, env=self.env,
  File "/app/.heroku/python/lib/python3.8/subprocess.py", line 858, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
 File "/app/.heroku/python/lib/python3.8/subprocess.py", line 1585, in _execute_child
and os.path.dirname(executable)
  File "/app/.heroku/python/lib/python3.8/posixpath.py", line 152, in dirname
p = os.fspath(p)
TypeError: expected str, bytes, or os.PathLike object, not NoneType

'''

我无法理解此类错误的原因。我在这里想念什么。

标签: pythonseleniumheroku-cli

解决方案


推荐阅读