Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
EOF while parsing
#1
Hi, so I am starting to get some unusual errors on some of my python scripts. it randomly giving an error like "IndentationError: expected an indented block" when I add a new line. So, then I remove that line and it gives the same error on the next line, and I keep repeating it until there is no lines left, then it says "EOF while parsing". I tried reopening the code editor (VS code), but it did not work. This is really getting annoying as there is nothing I can do to fix it.

Here is the most recent script that it gave the error:

#------------------------ Import Bay ------------------------
import pygame
#------------------------ loading bay------------------------

pencil = pygame.image.load("Assets/tools/Pencil_tool/Pencil_tool_icon(Large)-export.png")
eraser = pygame.image.load("Assets/tools/Eraser_tool/Eraser_tool.png")



#------------------------ Variable Bay------------------------

version = "0.0.1"
running = True
current_tool = 0
colour = (255,255,255)


#------------------------Init Bay------------------------


pygame.init()


screen = pygame.display.set_mode((800,600))
canvas =  pygame.Surface((64, 64))
pre_show = pygame.Surface((64, 64))
pygame.display.set_caption("Pyxe")
icon = pygame.image.load("Assets/icons3.png")
pygame.display.set_icon(icon)


#------------------------Main Loop------------------------

screen.fill((62,53,70))
while running:
    pre_show.fill((0,0,0,0))
    mouse = pygame.mouse.get_pos()
    mouse_buttons = pygame.mouse.get_pressed()
    scaled_pos = (mouse[0] - 336, mouse[1] - 236 )
    pre_show.fill((0,0,0,0))
    
    
    for event in pygame.event.get():

        if event.type == pygame.QUIT:
            running = False
    
        if mouse_buttons[1]:
            pygame.draw.line(pre_show, colour ,(0,  0), scaled_pos)
        
        if event.type == pygame.MOUSEBUTTONUP:
            
    
    screen.blit(pre_show, (336, 236))
    screen.blit(canvas, (336, 236))
    screen.blit(pencil, (734, 60))
    screen.blit(eraser, (734, 120))
Here is the most recent error:

Error:
screen.blit(pre_show, (336, 236)) ^ IndentationError: expected an indented block
Thanks for helping
Reply
#2
Th last if statement needs a body. At the very least a docstring or pass statement. As it is the parser uses the next line as the body and complains the indent is wrong.
nilamo likes this post
Reply
#3
(Feb-04-2021, 02:19 PM)Leo_Red Wrote: Hi, so I am starting to get some unusual errors on some of my python scripts. it randomly giving an error like "IndentationError: expected an indented block" when I add a new line. So, then I remove that line and it gives the same error on the next line, and I keep repeating it until there is no lines left, then it says "EOF while parsing". I tried reopening the code editor (VS code), but it did not work. This is really getting annoying as there is nothing I can do to fix it.

Here is the most recent script that it gave the error:

#------------------------ Import Bay ------------------------
import pygame
#------------------------ loading bay------------------------

pencil = pygame.image.load("Assets/tools/Pencil_tool/Pencil_tool_icon(Large)-export.png")
eraser = pygame.image.load("Assets/tools/Eraser_tool/Eraser_tool.png")



#------------------------ Variable Bay------------------------

version = "0.0.1"
running = True
current_tool = 0
colour = (255,255,255)


#------------------------Init Bay------------------------


pygame.init()


screen = pygame.display.set_mode((800,600))
canvas =  pygame.Surface((64, 64))
pre_show = pygame.Surface((64, 64))
pygame.display.set_caption("Pyxe")
icon = pygame.image.load("Assets/icons3.png")
pygame.display.set_icon(icon)


#------------------------Main Loop------------------------

screen.fill((62,53,70))
while running:
    pre_show.fill((0,0,0,0))
    mouse = pygame.mouse.get_pos()
    mouse_buttons = pygame.mouse.get_pressed()
    scaled_pos = (mouse[0] - 336, mouse[1] - 236 )
    pre_show.fill((0,0,0,0))
    
    
    for event in pygame.event.get():

        if event.type == pygame.QUIT:
            running = False
    
        if mouse_buttons[1]:
            pygame.draw.line(pre_show, colour ,(0,  0), scaled_pos)
        
        if event.type == pygame.MOUSEBUTTONUP:
            
    
    screen.blit(pre_show, (336, 236))
    screen.blit(canvas, (336, 236))
    screen.blit(pencil, (734, 60))
    screen.blit(eraser, (734, 120))
Here is the most recent error:

Error:
screen.blit(pre_show, (336, 236)) ^ IndentationError: expected an indented block
Thanks for helping

Thanks a lot Heart Now it works!!
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020