Forum Stats

  • 3,733,521 Users
  • 2,246,780 Discussions


Python script erroring out with message IndentationError: expected an indented block

Anindya G
Anindya G Member Posts: 15
edited March 2019 in WebLogic Portal


I am creating a code in python to check the Garbage collection but its erroring out with the below error message as. Can anyone please help me out.

File "/u01/app/oracle/Middleware/user_projects/domains/base_domain/", line 11

    free = int(server.getJVMRuntime().getHeapFreeCurrent())/(1024*1024)


IndentationError: expected an indented block

#!/usr/bin/env python

import shutil

import os

wlsUserID = java.lang.System.getenv('wlsUserID')

wlsPassword = java.lang.System.getenv('wlsPassword')

connect(  url='t3://localhost:7010', adminServerName='AdminServer')



printf('#Java heap information for ')

for server in servers:

free = int(server.getJVMRuntime().getHeapFreeCurrent())/(1024*1024)

freePct = int(server.getJVMRuntime().getHeapFreePercent())

current = int(server.getJVMRuntime().getHeapSizeCurrent())/(1024*1024)

max = int(server.getJVMRuntime().getHeapSizeMax())/(1024*1024)






  • Anindya G
    Anindya G Member Posts: 15
    edited March 2019

    Can anyone please help out.

  • Anindya G
    Anindya G Member Posts: 15
    edited March 2019


    Can anyone please suggest on this.

    Thanks in advance.



  • User_2W8DF
    User_2W8DF Member Posts: 0 Green Ribbon

    Putting in an extra space or leaving one out where it is needed will surely generate an error message . Some common causes of this error include:

    •   Forgetting to indent the statements within a compound statement
    •   Forgetting to indent the statements of a user-defined function.

    The error message IndentationError: expected an indented block would seem to indicate that you have an indentation error. It is probably caused by a mix of tabs and spaces . The indentation can be any consistent white space . It is recommended to use 4 spaces for indentation in Python, tabulation or a different number of spaces may work, but it is also known to cause trouble at times. Tabs are a bad idea because they may create different amount if spacing in different editors .

Sign In or Register to comment.