I am not a programmer and am trying to learn by doing (a retiree). I’ve entered the Python code for Project #2 and am getting the following error:
Traceback (most recent call last):
- File “/home/emetzler/motor.py”, line 8, in *
- response = client.digitalWrite(motorA1A, ‘LOW’)*
NameError: name ‘client’ is not defined
The text from Bolt says we define ‘client’ but I don’t see where that is done. I have checked and my coding follows the example Python code in the instructions exactly. Can anyone help?
Hi.@edwardmetzler the python code is case sensitive.so do check and be careful about the uppercase and lowercase characters.
I copied and pasted. I don’t see any code that defines the word “client” in the instructions. Can you tell me how it is defined for the later code?
Try by importing client
if you are using dropbox then try
“from dropbox import client”
Unfortunately, neither of these worked. This is just the beginning of the projects on BoltIoT and should be easiest yet there are typos in the code on the documents page and this problem with “client” exists. I am thinking this was a waste of money. Surely there is a simple solution.
Here is my code:
from boltiot import Bolt
api_key = “XXXX-XXXX-XXXX-XXXX”
d_id = “BOLT8021980”
motorA1A = 0
motorA1B = 1
response = client.digitalWrite(motorA1A, ‘LOW’)
response = client.digitalWrite(motorA1B, ‘HIGH’)
response = client.digitalWrite(motorA1A, ‘HIGH’)
response = client.digitalWrite(motorA1B, ‘LOW’)
Please do not share your device id and api key.
try this in the beginning
if this gives error with http then try
from . import http
You have not initialized Bolt object that has the digitalWrite function.
Add this line just below the api_key and d_id parameter initialization.
client = Bolt(api_key, d_id)
Do not share the api key anywhere. I have updated your question and removed your API to avoid misuse. I would still suggest to re-generate the api key by visiting the cloud account.