NameError: name 'client' is not defined [closed] - python

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 days ago.
Improve this question
Traceback (most recent call last): File "/home/Budget.py", line 11, in response = client.create_budget(parent="billingAccounts/"+billingAccountId, budget=budgets_v1.Budget(display_name=displayName, budget_filter=budgets_v1.Filter({"projects":str(budgetFilter)}), amount=budgets_v1.BudgetAmount(specified_amount=budgetAmount), threshold_rule=budgets_v1.ThreshholdRule(threshold_percent=thresholdPercent))) NameError: name 'client' is not defined
This is my response when I ran the py script

Related

Traceback, 'module' has no attribute I don't know why [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
test.py
import telebot
import config
bot = telebot.Telebot(config.TOKEN)
#bot.message_handler(content_types=['text'])
def lalala(message):
bot.send_message(message.chat.id, message.text)
bot.polling(non_stop=True)
config.py
TOKEN='1030045171:AAFPptKPt0a7xcoev9ryIMb6jXEIck5QfOs'
gives error:
Traceback (most recent call last):
File "C:\Users\User\Desktop\telegram\test.py", line 4, in <module>
bot = telebot.Telebot(config.TOKEN)
AttributeError: module 'telebot' has no attribute 'Telebot'
You misspelled TeleBot
import telebot
bot = telebot.TeleBot("TOKEN")
From the docs

tensorflow attribute error initialize_all_variables [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I am new to tensorflow. Following is the program I was trying to run.
import numpy as np
import tensorflow as tf
with tf.Session() as sess:
x=tf.placeholder("float",[1,3])
relu_out=x
num_layers=2
for layer in range(num_layers):
w=tf.Variable(tf.random_normal([3,3]))
b=tf.Variable(tf.zeros([1,3]))
relu_out=tf.nn.relu(tf.matmul(relu_out,w)+b)
softmax_w=tf.Variable(tf.random_normal([3,3]))
softmax_b=tf.Variable(tf.zeros([1,3]))
logit=tf.matmul(relu_out,softmax_w)+softmax_b
softmax=tf.nn.softmax(logit)
answer=np.array([[0.0,1.0,0.0]])
labels=tf.placeholder("float",[1,3])
cross_entropy=tf.nn.softmax_cross_entropy_with_logits(relu_out,labels,name='xentropy')
optimizer=tf.train.GradientDescentOptimizer(0.1)
train_op=optimizer.minimize(cross_entropy)
sess.run(tf.initialize_all_vraiables())
for step in range(10):
sess.run(train_op,feed_dict={x:np.array([[1.0,2.0,3.0]]),labels:answer})
It is showing following error:
Traceback (most recent call last):
File "/home/nilay/gdrive/REU/summer_exp/tf_tut/tf_add_layers.py", line 20, in <module>
sess.run(tf.initialize_all_vraiables())
AttributeError: 'module' object has no attribute 'initialize_all_vraiables'
Please help me resolve it.
There's a typo in your code:
is tf.initialize_all_variables not tf.initialize_all_vraiables

Class name not defined when instantiating [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
Learning Python, please go easy
I have removed all other methods defined in this class, here is the skeleton of whats left :
from random import randint
class CreditCardNumberGenerator:
def __init__(self):
print "Hello World"
pass
if __name__ == "__main__":
o = CreditCardNumberGenerator()
Error
Traceback (most recent call last):
File "del.py", line 3, in <module>
class CreditCardNumberGenerator:
File "del.py", line 11, in CreditCardNumberGenerator
o = CreditCardNumberGenerator()
NameError: name 'CreditCardNumberGenerator' is not defined
i have checked name, typecase and all possible SO thread, no help....can some one please advice??
I am pretty sure, its something very obvious which i am missing here!!! :\
if __name__ == "__main__":
o = CreditCardNumberGenerator()
is too much indented - make it aligned to the same column as class and it should be OK.

AttributeError: 'str' object has no attribute 'isoformat' [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have code, and I don't know how to solve problem. Code:
import dateutil.parser
import datetime
from novaclient.v2 import client as nova_client
from keystoneclient.auth.identity import v2
from keystoneclient import session
auth=v2.Password(auth_url="http://openstack2-prakt.in.linux.edu.lv:5000/v2.0",
username="***",
password="****",
tenant_name="********")
sess=session.Session(auth=auth)
nova=nova_client.Client(version="2", session=sess)
usage_list=nova.usage.get(tenant_id="**************",start='%Y-%m-%d', end='%Y-%m-%d')
for us in usage_list:
print us.total_vcpus_usage
After I execute code, there is next problem:
No handlers could be found for logger "keystoneclient.auth.identity.base"
Traceback (most recent call last):
File "/home/eleonora/PycharmProjects/untitled/nova test.py", line 32, in <module>
usage_list=nova.usage.get(tenant_id="c56f75091edc4480a204e5549ef11664",start='%Y-%m-%d', end='%Y-%m-%d')
File "/usr/local/lib/python2.7/dist-packages/novaclient/v2/usage.py", line 60, in get
(tenant_id, start.isoformat(), end.isoformat()),
AttributeError: 'str' object has no attribute 'isoformat'
'%Y-%m-%d' is not datetime object but string but you (or some other code) are trying to use it as datetime object.
The one of several answers is:
now=datetime.datetime.now()
later=now+datetime.timedelta(seconds=30)
usage_list=nova.usage.get(tenant_id="cb076df2-6855-4988-95c0-e3ea2aa4729c",start=now, end=later)

I don't know why I'm recieving this function error - Python [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I am writing an inventory 'system' in python.
import time, math, items
from pygame.locals import *
while 1:
def additem(item):
if item in items:
items.extend(item)
print(item+' has been succefully added to your inventory.')
else:
print("Invalid command.")
This is items.py
items = ['sword','cheese']
I recieve the error:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
additem(sword)
NameError: name 'additem' is not defined
You have a list called items inside a module named items, when you call additem you are going to be checking if item in the module items not the list items, so you will get another error.
Either use from items import items or change the name of your items list.
Your error is most likely from calling additem(sword) above your function additem

Categories