Issue compiling smart contract using py-algorand-sdk

I am using algoexplorer api service to compile the code for smart contract, but I receive the following error:

Here I am using py-algorand-sdk in my development. The algorand client address that I used is

Any ideas on this kind of error? has an issue with the Python urllib user agent, see Requests fails if a server is behind CloudFlare · Issue #169 · algorand/py-algorand-sdk · GitHub

This code works:

from algosdk.v2client import algod

# create an algod client
algod_token = ""
algod_address = ""
algod_client = algod.AlgodClient(algod_token, algod_address, headers={'User-Agent': 'DoYouLoveMe?'})


# simplest TEAL program
data = "int 1"
# compile teal program
response = algod_client.compile(data)

print("Response Result = ",response['result'])
print("Response Hash = ",response['hash'])

For the sake of completeness, I post here the error we get when headers are not set:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/algosdk/v2client/", line 77, in algod_request
    raise error.AlgodHTTPError(json.loads(e)["message"], code)
  File "/usr/local/Cellar/python@3.9/3.9.4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/local/Cellar/python@3.9/3.9.4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/Cellar/python@3.9/3.9.4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "xxxx", line 8, in <module>
  File "/usr/local/lib/python3.9/site-packages/algosdk/v2client/", line 145, in status
    return self.algod_request("GET", req, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/algosdk/v2client/", line 79, in algod_request
    raise error.AlgodHTTPError(e, code)
algosdk.error.AlgodHTTPError: error code: 1010

[Note: I’ve moved your post to a new topic to allow users to more easily find it in the future.]