Token as None resulting into an error ( influxdb cloud)

hi wrote a very simple copy-paste of the influx cloud in my local computer and it is throwing me errors… I cant even start… Where is the error?
INFLUX_TOKEN = '27K5sZk0foqy9pTZTZEOLxlzwAxzZuSXnESDN8pzimo5SBE_noZdkyM9Ka1cZT6FET7kDZsBitNkXqS4q3D75g=='from datetime import datetime
import osfrom influxdb_client import InfluxDBClient, Point, WritePrecision
from influxdb_client.client.write_api import SYNCHRONOUS# You can generate an API token from the “API Tokens Tab” in the UI
token = os.getenv(INFLUX_TOKEN)
org = “anup.iit@gmail.com
bucket = "banknifty"with InfluxDBClient(url=“https://us-east-1-1.aws.cloud2.influxdata.com”, token=token, org=org) as client: write_api = client.write_api(write_options=SYNCHRONOUS) point = Point(“mem”)
.tag(“host”, “host1”)
.field(“used_percent”, 23.43234543)
.time(datetime.utcnow(), WritePrecision.NS) write_api.write(bucket, org, point) us-east-1-1.aws.cloud2.influxdata.com
InfluxDB Cloud
InfluxDB Cloud is a time series platform, purpose-built by InfluxData for storing metrics and events, provides real-time visibility into stacks, sensors, and systems.
errors I m getting → runcell(0, ‘E:/influxdb/python/test1.py’)
Exception ignored in: <function InfluxDBClient.del at 0x0000017052A88F70>
Traceback (most recent call last):
File “C:\Users\Roy\anaconda3\lib\site-packages\influxdb_client\client\influxdb_client.py”, line 353, in del
if self.api_client:
AttributeError: ‘InfluxDBClient’ object has no attribute ‘api_client’
Traceback (most recent call last): File “E:\influxdb\python\test1.py”, line 14, in
with InfluxDBClient(url=“https://us-east-1-1.aws.cloud2.influxdata.com”, token=token, org=org) as client: File “C:\Users\Roy\anaconda3\lib\site-packages\influxdb_client\client\influxdb_client.py”, line 79, in init
auth_header_value = "Token " + auth_tokenTypeError: can only concatenate str (not “NoneType”) to str .

Can anyone please help me? I see that the token is None. But why?

Hi @bluebird,

thanks for using our client.

auth_header_value = "Token " + auth_tokenTypeError: can only concatenate str (not “NoneType”) to str

It caused by missing value for token parameter. Try to change the:

token = os.getenv(INFLUX_TOKEN)

to

token = os.getenv('INFLUX_TOKEN')
print(token)

Regards