【问题标题】:'phantomjs' executable may have wrong permissions'phantomjs' 可执行文件可能有错误的权限
【发布时间】:2019-02-17 14:43:29
【问题描述】:

此脚本在 Google Cloud Service 上运行良好。但我在 Amazon Web Service EC2 上遇到错误:(操作系统:linux 64bit)

selenium.common.exceptions.WebDriverException: Message: 'phantomjs' executable may have wrong permissions.

完整代码:

 /usr/local/lib/python3.7/site-packages/selenium/webdriver/phantomjs/webdriver.py:49: UserWarning: Selenium support for PhantomJS has been deprecated, please use headless versions of Chrome or Firefox instead
  warnings.warn('Selenium support for PhantomJS has been deprecated, please use headless '
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 76, in start
    stdin=PIPE)
  File "/usr/lib64/python3.7/subprocess.py", line 756, in __init__
    restore_signals, start_new_session)
  File "/usr/lib64/python3.7/subprocess.py", line 1499, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: '/usr/local/share/phantomjs-2.1.1-linux-x86_64/bin/phantomjs'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "turkish.py", line 114, in <module>
    bot = TransBot()
  File "turkish.py", line 13, in __init__
    self.driver = webdriver.PhantomJS(executable_path='/usr/local/share/phantomjs-2.1.1-linux-x86_64/bin/phantomjs')
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/phantomjs/webdriver.py", line 56, in __init__
    self.service.start()
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 88, in start
    os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'phantomjs' executable may have wrong permissions.

我尝试移动 '/usr/local/bin' 和 '/usr/local/share' phantomjs 文件。同样的错误。你有什么建议?对不起我的英语。

【问题讨论】:

    标签: python selenium selenium-webdriver amazon-ec2 phantomjs


    【解决方案1】:

    更改权限使其可执行。

    $ chmod a+x phantomsjs

    【讨论】:

    • 哦,谢谢。我确实在终端中运行了“chmod a+x phantomsjs”。然后我得到错误:'phantomjs 意外退出。状态码是:127' 然后我安装 libfontconfig 并解决了问题。 'yum install fontconfig freetype freetype-devel fontconfig-devel libstdc++'
    【解决方案2】:

    授予对 phantomjs 文件的完全权限:

    sudo chmod a+rwx phantomjs 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-01-19
      • 2017-06-14
      • 1970-01-01
      • 1970-01-01
      • 2018-09-22
      • 2022-01-20
      • 2019-04-17
      相关资源
      最近更新 更多