Putty coding problem

I am unable to execute my code I follow but it didn’t work

  1. First I execute these commands
    sudo apt-get -y update
    sudo apt install python3-pip
    sudo pip3 install boltiot
  2. Then i create a file name sudo nano device_status.py
  3. Then i wrote the command with my api key and device id
    from boltiot import Bolt
    device_id = “BOLTXXXXXX”
    mybolt = Bolt(api_key, device_id)
    response = mybolt.isOnline()
    print (response)
    4.I save and exit the file and type sudo python3 device_status.py to run the code but it didn’t work it says syntax error

Please share the screenshot of the error

@alamhbk420 the screenshot of the error

@alamhbk420 you have stored the api_key and device_id in variables and then in the Bolt function you are using the strings themeselves even without a comma. Do share the corret code and error message.

I want the error message so that I can help you further :slight_smile:

Execute the command ls and then share the output screenshot

Have you intentionally made 03 files with almost same name?

You have to click Ctrl + X to save the file and then click Y and then hit enter. I think you must ne doing some error there.

yes i did what do you suggest what should i do

Make a new file and save it with a name say first.py and then run that file

can i have ur mail id so i can contact you directly

@alamhbk420 as you have created the file with the name device_status.py and in the command you are trying to open device_control.py

So correct the syntax:

sudo python3 device_status.py

This will solve your problem

@alamhbk420 Hello! As I can see in your latest screenshot, you have save your code with one file name 3 times, so you may create a new file and write your code. And you have assign string that is again you have write your API key and device id in line4 instead of that you have to write variable name only mybolt = Bolt(api_key,device_id), so make change there and one more thing after saving your code you are mentioning with different name of your file to run that. So also note that you have to run your file name as whatever you have given name. ex: if you have create file name with device_status.py so to run that file you have to write - sudo python3 device_status.py only.

@alamhbk420 see I am sharing the same code from my end. It is working fine. So I request you to create a new file and then run that file :slight_smile:




1 Like

@alamhbk420 if your problem is solved, please do close the query :grinning:

Dear @alamhbk420 , in your code you have written the API key and the device if without double quotes and also they are not seperated by a comma.

Write the code in the following manner:

from boltiot import Bolt
api_key = “uqb13-…”
device_id = “BOLTxxxxx”
mybolt = Bolt(api_key, device_id)
response = mybolt.isOnline()

Save the file by pressing Ctrl + X and then then Y and then enter.

Do write the correct credentials. In your code you haven’t defined the credentials as strings that is why the error was coming. You can also have a look at the screenshot which I pasted in the previous post. You just have to do the same.