@Jimmy1502
You will need to comment the try, too. Additionally the indention of the code needs to be changed.
The file will be look like this then:
#!/bin/python3
#Install Dependencies:
# pip3 install adafruit-circuitpython-dht
# sudo apt-get install libgpiod2
import time
import board
import adafruit_dht
import json
import sys
gpio_nr = 4
if len(sys.argv) > 1:
gpio_nr = int(sys.argv[1])
# Initial the dht device, with data pin connected to:
dhtDevice = adafruit_dht.DHT22(getattr(board, "D%d"%gpio_nr))
result = {}
result["temperature_c"] = dhtDevice.temperature
result["humidity"] = dhtDevice.humidity
result["temperature_f"] = (result["temperature_c"]*1.8) + 32
result["error"] = False
print(json.dumps(result))