Image won’t save Python pyautogui

I’m trying to take a screenshot in Python and I’m trying to save the image, but it gives me an error

This is the code:

import pyautogui as pygui

def take_screenshot():
    ss = pygui.screenshot()
    cd = os.getcwd()
    ss.save(cd+"/Data/Screenshots/Screenshot.png")

This is the error code:

  File "Main.py", line 67, in <module>
    scan_func()
  File "Main.py", line 53, in scan_func
    take_screenshot()
  File "/home/user/IXL-Bot/Data/ExternalModules/ScreenshotModules.py", line 7, in take_screenshot
    ss.save(cd+"/Data/Screenshots/Screenshot.png")
  File "/home/user/.local/lib/python3.7/site-packages/PIL/Image.py", line 2232, in save
    fp = builtins.open(filename, "w+b")
FileNotFoundError: [Errno 2] No such file or directory: '/home/user/IXL-Bot/Data/Screenshots/Screenshot.png'

Answer

When edited the code slightly, it worked perfectly for me.

Try This:

import pyautogui as pygui
import os  #You dont seem to have included this in your example code

def take_screenshot():
    ss = pygui.screenshot()
    cd = os.getcwd()
    print(cd+/Data/Screenshots/Screenshot.png) #Check if the path it 
                                               #specifying is correct
    ss.save(cd+"/Data/Screenshots/Screenshot.png")