1

I want to create a program in pythonista that can control the web browser. I know Selenium is the best for this but I have tried it on pythonista for my iOS iPhone and I get an error.

This is the code:

from selenium import webdriver

browser = webdriver.Chrome()
browser.get('http://www.yahoo.com')

Here is the error:

PermissionError: [Errno 1] Operation not permitted
Traceback (most recent call last):
  File "/private/var/mobile/Containers/Shared/AppGroup/A2EBDF28-CB6C-4190-8199-7406AA3821A3/Pythonista3/Documents/selen.py", line 3, in <module>
    browser = webdriver.Chrome()
  File "/private/var/mobile/Containers/Shared/AppGroup/A2EBDF28-CB6C-4190-8199-7406AA3821A3/Pythonista3/Documents/site-packages-3/selenium/webdriver/chrome/webdriver.py", line 68, in __init__
    self.service.start()
  File "/private/var/mobile/Containers/Shared/AppGroup/A2EBDF28-CB6C-4190-8199-7406AA3821A3/Pythonista3/Documents/site-packages-3/selenium/webdriver/common/service.py", line 76, in start
    stdin=PIPE)
  File "/var/containers/Bundle/Application/24DD2A57-320E-4E21-9BE2-7C3605830DE0/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/subprocess.py", line 708, in __init__
    restore_signals, start_new_session)
  File "/var/containers/Bundle/Application/24DD2A57-320E-4E21-9BE2-7C3605830DE0/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/subprocess.py", line 1261, in _execute_child
    restore_signals, start_new_session, preexec_fn)
PermissionError: [Errno 1] Operation not permitted
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Lemonds
  • 11
  • 1
  • 3

1 Answers1

2

This error message...

PermissionError: [Errno 1] Operation not permitted

...implies that the ChromeDriver was unable to create a desired new resource e.g. logfile while initializing a new WebDriver and Web Client session.

As per the discussion Pythonista - Limitations due to iOS following are some of the limitations while using Pythonista :

  • No fork/exec for new processes. Impacts the subprocess module.
  • Due to missing fork, no full cleanup of process resources (memory, threads, file handles).
  • No file access outside of application directory.
  • No /dev/null and other special files.
  • Limited processing power of devices (compared to typical PC/Mac).
  • Process usually is stopped/killed after a while.

An simple example is as follows :

>>> import subprocess
>>> subprocess.call(["ls", "-l"])
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/private/var/mobile/Containers/Bundle/Application/8C59C68D-71BF-4CBB-90F8-373A1752DEE1/Pythonista.app/pylib/subprocess.py", line 524, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/private/var/mobile/Containers/Bundle/Application/8C59C68D-71BF-4CBB-90F8-373A1752DEE1/Pythonista.app/pylib/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/private/var/mobile/Containers/Bundle/Application/8C59C68D-71BF-4CBB-90F8-373A1752DEE1/Pythonista.app/pylib/subprocess.py", line 1205, in _execute_child
    self.pid = os.fork()
OSError: [Errno 1] Operation not permitted

What's wrong in your usecase

There can be 2 issues as follows :

  • When you invoke the following line of code :

    browser = webdriver.Chrome()
    

    The ChromeDriver tries to create/modify/access the scoped_directory within the file system. For example on Windows OS :

    "chromedriverVersion": "2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73)",
    "userDataDir": "C:\\Users\\username\\AppData\\Local\\Temp\\scoped_dir5188_12717"
    

    Possibly ChromeDriver is unable to perform this task/method/functionality.

  • Again when you invoke the following line of code :

    browser = webdriver.Chrome()
    

    As per selenium.webdriver.chrome.webdriver ChromeDriver tries to create a logfile within the file system as per the constructor as follows :

    class selenium.webdriver.chrome.webdriver.WebDriver(executable_path='chromedriver', port=0, options=None, service_args=None, desired_capabilities=None, service_log_path=None, chrome_options=None)
    

    Possibly ChromeDriver is unable to perform this task/method/functionality,

Due to the above mentioned reasons you are seeing the error :

PermissionError: [Errno 1] Operation not permitted

Solution

Incase of any of the above mentioned cases the solution would be to restrict the access/creation of the resources within the application directory only.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352