Error: Received command c on object id p0

You see the error message `INFO:py4j.java_gateway:Received command c on object id p0` after running Python code with imported libraries.

Written by rakesh.parija

Last published at: August 21st, 2023

Problem

You have imported Python libraries, but when you try to execute Python code in a notebook you get a repeating message as output.

Example 1:

INFO:py4j.java_gateway:Received command c on object id p0
INFO:py4j.java_gateway:Received command c on object id p0
INFO:py4j.java_gateway:Received command c on object id p0
INFO:py4j.java_gateway:Received command c on object id p0
INFO:py4j.java_gateway:Received command c on object id p0
INFO:py4j.java_gateway:Received command c on object id p0
INFO:py4j.java_gateway:Received command c on object id p0

Example 1:

INFO:py4j.clientserver:Received command c on object id p0
INFO:py4j.clientserver:Received command c on object id p0
INFO:py4j.clientserver:Received command c on object id p0
INFO:py4j.clientserver:Received command c on object id p0
INFO:py4j.clientserver:Received command c on object id p0
INFO:py4j.clientserver:Received command c on object id p0

Cause

The default log level for py4j.java_gateway/py4j.clientserver are ERROR.

If any of the imported Python libraries set the log level to INFO you will see this message.

Solution

You can prevent the output of the INFO messages by setting the log level back to ERROR after importing the libraries.

%python

import logging
logger = spark._jvm.org.apache.log4j
logging.getLogger("py4j").setLevel(logging.ERROR)

 

 

Was this article helpful?