Use try: ... except: ... to catch the exception and continue
for p in range(6):
for d in range(2):
for q in range(4):
try:
arima_mod=sm.tsa.ARIMA(df,(p,d,q)).fit(transparams=True)
x=arima_mod.aic
x1= p,d,q
print (x1,x)
aic.append(x)
pdq.append(x1)
except:
pass
# ignore the error and go on