attributeerror

AttributeError: 'NoneType' object has no attribute 'write'

╄→гoц情女王★ 提交于 2019-12-25 10:56:10
问题 I am trying to run a game me and my friends made in python... It was sent to me by e-mail. i know i have a newer version of python but im not sure if that is the problem. This is the function we defined: def text(x,y,text,size): turtle.penup() turtle.goto(x,y) turtle.pendown() turtle.write(text,font=('Arial',size,'normal')) we call it here: def home_screen(): turtle.bgpic("bgarmy.gif") turtle.fillcolor("#46B347") turtle.fill(True) rectangle(-150,100,300,100) turtle.fill(False) text(-70,130,

Django: AttributeError using ratings app

夙愿已清 提交于 2019-12-25 09:35:10
问题 This is somewhat an extension of my previous question, but after solving that problem I am getting a different AttributeError . This one reads '_RatingsDescriptor' object has no attribute 'cumulative_score' when trying to do something like this in my view: def index(request): thing_list = Thing.ratings.cumulative_score() return render(request, 'index.html', {'thing_list':thing_list}) My model: from ratings.models import Ratings class Thing(models.Model): user = models.ForeignKey(User) ...

AttributeError: 'module' object has no attribute 'textinput'

余生颓废 提交于 2019-12-25 09:19:52
问题 I use Sublime Text and have a problem with that code: #coding: utf-8 import turtle turtle.circle(20) answer = turtle.textinput("Title", "Text") When i run it, i get: AttributeError: 'module' object has no attribute 'textinput' How can i fix it? 回答1: You are using Python 2. Run import sys print(sys.version) and it will probably output something like 2.7.12 (v2.7.12:d33e0cf91556, Jun 26 2016, 12:10:39) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] which means that you are using Python 2. As

Speech Recognition: AttributeError: module 'speech_recognition' has no attribute 'Recognizer'

谁说胖子不能爱 提交于 2019-12-24 19:57:39
问题 I'm trying to run a speech recognition using the Speech Recognition Project I installed SpeechRecognition as illustrated. My code ran correctly for a few times. I was trying to input different files. Now I started getting the following error: import speech_recognition as sr Traceback (most recent call last): File "<ipython-input-1-a4d5c9aae5d0>", line 1, in <module> import speech_recognition as sr File "/Users/Sashank/Documents/Deep_Learning_A_Z/Personal Projects/Speech recognition/speech

Python 3 AttributeError even though attribute exists

偶尔善良 提交于 2019-12-24 07:26:43
问题 I have a set of python files which make up a program for saving tidbits of info and searching them via tag association. I had the program working for many versions, but I recently made what I thought was a minor change that caused the program to go haywire. The ENTRY object is the basis of the data storage - it holds a unique ID number, a nickname, a value, and a list of tags. class ENTRY: def __init__(self, idNum, nickName, value, tagList): self.idNum = idNum self.nickName = nickName self

Pandas groupby and describe flags AttributeError

孤街醉人 提交于 2019-12-24 05:26:06
问题 I have a bunch of data stored in vals . The indices are monotonic, but not continuous. I'm attempting to do some analysis on histograms of the data, so I've created the following structure: hist = pd.DataFrame(vals) hist['bins'] = pd.cut(vals, 100) This is data taken from an experimental instrument and I know that some of the bins have only 1 or 2 counts in them, which I'm trying to remove. I've tried using groupby as follows and get the following error (Full traceback included at the end of

Can't read_excel with pandas

独自空忆成欢 提交于 2019-12-24 01:58:54
问题 I am learning pandas lib. in Python3, but i have a big problem. When i use command to read_excel i get an error. import pandas as pd df = pd.read_excel(r'D:\PythonProjects\stocks.xlsx',sheetname=0) The error looks like this: C:\Users\Kuba\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\util\_decorators.py:118: FutureWarning: The `sheetname` keyword is deprecated, use `sheet_name` instead return func(*args, **kwargs) Traceback (most recent call last): File "D:/MyPythonProjects

python - AttributeError: 'module' object has no attribute

人盡茶涼 提交于 2019-12-24 00:37:22
问题 I'm trying this simple code: import requests print requests.__file__ r = requests.get('https://github.com/timeline.json') It works flawlessly on the command line when I type the lines one by one, but not whenen when I execute it as a script or in Sublime Text 2. Here's the stack trace: C:\Python27\lib\site-packages\requests\__init__.pyc Traceback (most recent call last): File "C:\Users\Bruce\Desktop\http.py", line 1, in <module> import requests File "C:\Python27\lib\site-packages\requests\_

Exception AttributeError: “'NoneType' object has no attribute 'path'” in

孤街浪徒 提交于 2019-12-24 00:23:07
问题 I am debugging python code (python2.7.12) as my code works but I get NULL for all variables when streaming tweets into the database. The error I got is: Exception AttributeError: "'NoneType' object has no attribute 'path'" in <function _remove at 0x10068f140> ignored I am assuming this error is from the code below: def put_tweets_in_database(tweets): print "putting tweets in database" errors = 0 count = 0 for tweet in tweets: try: commit_tweet_to_database(tweet, count, len(tweets)) count += 1

AttributeError: Unknown property density

本秂侑毒 提交于 2019-12-23 08:04:15
问题 I am trying to get a hold of SciPy, but I am stuck with Unknown property density error, even though I copied the whole code from official SciPy documentation. This part worked fine: x = np.linspace(norm.ppf(0.01), norm.ppf(0.99), 100) ax.plot(x, norm.pdf(x), 'r-', lw=5, alpha=0.6, label='norm pdf') rv = norm() ax.plot(x, rv.pdf(x), 'k-', lw=2, label='frozen pdf') r = norm.rvs(size=1000) But the following part gives me the AttributeError: Unknown property density : ax.hist(r, density=True,