attributeerror

Beginner Python: AttributeError: 'list' object has no attribute

折月煮酒 提交于 2021-02-17 12:24:26
问题 The error says: AttributeError: 'list' object has no attribute 'cost' I am trying to get a simple profit calculation to work using the following class to handle a dictionary of bicycles: class Bike(object): def __init__(self, name, weight, cost): self.name = name self.weight = weight self.cost = cost bikes = { # Bike designed for children" "Trike": ["Trike", 20, 100], # Bike designed for everyone" "Kruzer": ["Kruzer", 50, 165] } When I try to calculate profit with my for statement, I get the

Beginner Python: AttributeError: 'list' object has no attribute

烈酒焚心 提交于 2021-02-17 12:24:13
问题 The error says: AttributeError: 'list' object has no attribute 'cost' I am trying to get a simple profit calculation to work using the following class to handle a dictionary of bicycles: class Bike(object): def __init__(self, name, weight, cost): self.name = name self.weight = weight self.cost = cost bikes = { # Bike designed for children" "Trike": ["Trike", 20, 100], # Bike designed for everyone" "Kruzer": ["Kruzer", 50, 165] } When I try to calculate profit with my for statement, I get the

Getting Started with Python: Attribute Error

Deadly 提交于 2021-02-16 14:49:06
问题 I am new to python and just downloaded it today. I am using it to work on a web spider, so to test it out and make sure everything was working, I downloaded a sample code. Unfortunately, it does not work and gives me the error: "AttributeError: 'MyShell' object has no attribute 'loaded' " I am not sure if the code its self has an error or I failed to do something correctly when installing python. Is there anything you have to do when installing python like adding environmental variables, etc.

Tkinter python 3.7 AttributeError: 'Button' object has no attribute 'get'

若如初见. 提交于 2021-02-11 17:01:23
问题 I'm writing an inventory database program. I'm a novice so I'm sure I have something wrong. def select_item(): #Create a Database or Connect to one conn = sqlite3.connect('inventory.db') #Create Cursor c = conn.cursor() a = id_select.get() c.execute("SELECT * FROM inventory WHERE oid = " + a) records = c.fetchall() for record in records: Item_editor.insert(0, record[0]) Quantity_editor.insert(0, record[1]) Asset_tag_editor.insert(0, record[2]) Notes_editor.insert(0, record[3]) #Entry Fields

module 'a' has no attribute func()

放肆的年华 提交于 2021-02-11 13:46:30
问题 I have 2 modules: a: import another_module def func(): b: import a x=a.func() This is showing error: module 'a' has no attribute 'func'. What i am doing wrong in importing a.ipynb 回答1: Make sure your module is names 'a.py', and it is in the same folder as b, otherwise, in the place where all the other modules are stored. 来源: https://stackoverflow.com/questions/61870325/module-a-has-no-attribute-func

AttributeError: tkagg has no attribute cursord

随声附和 提交于 2021-02-10 20:40:01
问题 I recently reinstalled anaconda to shift the directory over from an admin account to my personal account. Previously, I had no issue with the code below import matplotlib.backends.backend_tkagg as tkagg defaultcursor = tkagg.cursord[1] Now, it gives the following error: AttributeError: module 'matplotlib.backends.backend_tkagg' has no attribute 'cursord' any idea why this is happening? 来源: https://stackoverflow.com/questions/54002098/attributeerror-tkagg-has-no-attribute-cursord

AttributeError: tkagg has no attribute cursord

亡梦爱人 提交于 2021-02-10 20:38:20
问题 I recently reinstalled anaconda to shift the directory over from an admin account to my personal account. Previously, I had no issue with the code below import matplotlib.backends.backend_tkagg as tkagg defaultcursor = tkagg.cursord[1] Now, it gives the following error: AttributeError: module 'matplotlib.backends.backend_tkagg' has no attribute 'cursord' any idea why this is happening? 来源: https://stackoverflow.com/questions/54002098/attributeerror-tkagg-has-no-attribute-cursord

AttributeError: 'Turtle' object has no attribute 'shapesize' on line 14

眉间皱痕 提交于 2021-02-10 18:35:15
问题 I'm trying to make a turtle game on Repl.it and I don't know why this error keeps coming up. Here is my code: import turtle wn = turtle.Screen() wn.bgcolor("white") wn.setup(width=800, height=800) wn.tracer(0) # Set up the ground ground = turtle.Turtle() ground.color("white") ground.shape("square") ground.speed(0) ground.shapesize(stretch_wid=200, stretch_len=20) ground.speed(0) ground.color("black") ground.penup() ground.goto(0, -400) ground.direction = "stop" 回答1: It seems that the

Python: Why am I receiving an AttributeError: __enter__

独自空忆成欢 提交于 2021-02-10 05:14:32
问题 I am not reassigning the open keyword yet still receive this error. Any suggestions or direction to fix my error? with tempfile.mkdtemp() as test_dir: print(test_dir) AttributeError: __enter__ I am also new to python and I am having a hard time understanding these concepts. 回答1: You're using mkdtemp incorrectly. mkdtemp returns the path name as str, not a context manager. If you want a context manager for managing a temporary directory, you need to use TemporaryDirectory, which is available

matplotlib - module 'sip' has no attribute 'setapi'

醉酒当歌 提交于 2021-02-08 12:35:35
问题 I just set up the VS Code with all the Python extensions. Python version is 3.8.3 through Anaconda. The interpreter is venv. When I run this code import matplotlib.pyplot as plt An error shows - Exception has occurred: AttributeError module 'sip' has no attribute 'setapi' File "C:\test.py", line 145, in <module> import matplotlib.pyplot as plt I've tried uninstalling and reinstalling matplotlib, but to no avail. 回答1: This worked for me. python -m pip install matplotlib==3.2 回答2: There seems