添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

OSError: [WinError 1450] Insufficient system resources exist to complete the requested service using Selenium in Python through Anaconda

Ask Question

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...

OSError: [WinError 1450] Insufficient system resources exist to complete the requested service

...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"

  • If Windows 10 has no enough inner memory resources to create the system image, then you will get stuck on the system error "insufficient system resources exist to complete the requested service". A registry modification could release the pain.
  • Use Windows shortcut keys Win + R to open the Run.
  • Type into regedit.
  • Hit the Enter.
  • Expand the entry for the subkey: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer.
  • Highlight the LanmanServer and right-click the blank area on the right pane.
  • Select the New and DWORD (32-bit) Value.
  • Name the new entry as maxworkitems.
  • Double-click the new entry and type 1024 into the Value data box.
  • Click the OK. (Note: If your computer memory storage is less than 512M, type 256 into the box.)
  • Go to the subkey: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management.
  • Highlight the Memory Management.
  • On the right side, right-click the blank area to create a new DWORD (32-bit) Value.
  • Name the new entry as PoolUsageMaximum.
  • Change the Value data to 60 and choose the Decimal option.
  • Click the OK.
  • Restart the computer.
  • Note: Registry Editor is a database storing important Windows data. You'd better backup registry before any modification in case other serious system errors occur, such as black screen problem, boot loop issue, "system cannot find the file specified" error, etc.
  • B. Scan Disk Drive to Fix the Error

  • The faulty disk drive can result in the error "insufficient system resources exist to complete the requested service" and other storage problems, such as high memory usage issue, memory leak issue, 100% disk usage problem, etc. So it may be necessary to take a scan to check the disk.
  • Open This PC on Windows 10.
  • Right-click the C: drive and select Properties.
  • Go to the Tools tab.
  • Click the Check button.
  • Click the Scan drive.
  • Then Windows 10 will start checking. If errors are found, you can follow the on-screen instructions to fix them.
  • After that, you can also click the Optimize button on the C: drive Properties to optimize the drive.
  • @DebanhanB I've tried option B and the scan did not find anything. Is modifying the registry safe? How do I back it up? – Mariah Akinbi Dec 13, 2018 at 14:42 @MariahAkinbi By default the old registry gets saved within the desktop. FYI there is also a third fixing option mentioned in the link Fix "Insufficient System Resources Exist to Complete the Requested Service" Error on Windows 10 which I have provided in my answer. – undetected Selenium Dec 13, 2018 at 14:44

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.