I've been running the same python script using windows task scheduler for the past month, then all of a sudden the script runs into an Insufficient Resources
error (see below). My CPU and RAM are at normal levels (CPU is <10% and RAM is <20%) when I try to run the program. I have quadrupled both the CPU and RAM on the virtual machine, but I still get the same error.
This is the code I'm trying to run:
from selenium import webdriver
browser = webdriver.Firefox()
This is the error I'm getting:
Traceback (most recent call last):
File "Desktop\Scripts\Selenium_file.py", line 34, in <module>
browser = webdriver.Firefox()
File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 164, in __init__
self.service.start()
File "C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\common\service.py", line 76, in start
stdin=PIPE)
File "C:\ProgramData\Anaconda3\lib\subprocess.py", line 756, in __init__
restore_signals, start_new_session)
File "C:\ProgramData\Anaconda3\lib\subprocess.py", line 1155, in _execute_child
startupinfo)
OSError: [WinError 1450] Insufficient system resources exist to complete the requested service
I've uninstalled and reinstalled selenium and get the same error.
I've checked the COMSPEC variable like this post suggested:
>>> import os
>>> os.environ['COMSPEC']
'C:\\Windows\\system32\\cmd.exe'
I've also checked the cpu and memory using psutil:
>>> import psutil
>>> psutil.cpu_times()
scputimes(user=237.75, system=402.5625, idle=7884.859375, interrupt=2.421875, dpc=3.71875)
>>> psutil.virtual_memory()
svmem(total=17179398144, available=14275997696, percent=16.9, used=2903400448, free=14275997696)
This error message...
...implies that the Python Client was unable to complete a particular requested service.
This error doesn't seem to be Selenium related but involves the Python Client and the underlying Operating System.
However, as per "Insufficient System Resources Exist to Complete the Requested Service" Error on Windows often occurs on the Windows 10 OS when you leave your computer on for a long time, when you plug into a USB drive, or when you're trying to launch some .exe files like the Chrome browser, iTunes, Microsoft Edge, etc. Then the computer will get freezing or stuttering. After a PC reboot, the error may happen again and stop your computing.
Solution
The two most frequently used approach are as follows:
A. Modify Registry to Fix "Insufficient System Resources Exist to Complete the Requested Service"
regedit
.HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer
.DWORD
(32-bit) Value.maxworkitems
.1024
into the Value data box.HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management
.DWORD
(32-bit) Value.PoolUsageMaximum
.60
and choose the Decimal option.B. Scan Disk Drive to Fix the Error
C:
drive and select Properties.C:
drive Properties to optimize the drive.