出于某些原因,在终端中时,我在文件中的python中没有正确的权限

问题描述 投票:0回答:1

这是我到目前为止的代码:

from selenium import webdriver
import bs4
ask_page = input('retrieve what dial: ')
if ask_page == '':
    ask_page = 'bm056'

driver = webdriver.Firefox(executable_path=r'/home/neal/Downloads/geckodriver-v0.24.0-linux32')
soup = driver.get(f"http://www.hcrealms.com/forum/units/units_bbcode.php?id={ask_page}")
print(soup)

返回此错误:

Traceback (most recent call last):
   File "/home/user/.local/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 76, in start
stdin=PIPE)
  File "/usr/lib/python3.7/subprocess.py", line 800, in __init__
restore_signals, start_new_session)
  File "/usr/lib/python3.7/subprocess.py", line 1551, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: '/home/user/Downloads/geckodriver-v0.24.0-linux32'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/PycharmProjects/heroclix_app/scraper.py", line 8, in <module>
driver = webdriver.Firefox(executable_path=r'/home/user/Downloads/geckodriver-v0.24.0-linux32')
   File "/home/user/.local/lib/python3.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 164, in __init__
self.service.start()
  File "/home/user/.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: 'geckodriver-v0.24.0-linux32' executable may have wrong permissions. 

这里是我更改权限和输出内容:

:~/Downloads$ chmod +x geckodriver
:~/Downloads$ ll geckodriver
-rwxr-xr-x 1 user user 8091065 Jan 28  2019 geckodriver*

但是我得到相同的错误代码。

python linux selenium permissions geckodriver
1个回答
0
投票

请确保geckodriver(或其他Webdriver)可执行文件实际上是可执行文件(chmod +x path/to/geckodriver),并且在文件中引用了正确的路径。如果不确定,使用whereis geckodriver这样的命令可以帮助查找可执行文件的位置。

© www.soinside.com 2019 - 2024. All rights reserved.