FAQ Database Discussion Community


Using StringIO , no keyword arguments

python,csv,typeerror,bokeh,stringio
I am attempting to read in a csv file using read_csv. I am very confused, since the code works when one types in the csv manually. from six.moves import cStringIO as StringIO Companies=""" Top, Equipment, Users, Neither Company 1, 0, 0, 43 Company 2, 0, 0, 32 Company 3, 1,...

Python: TypeError: 'int' object is not subscriptable

python,list,tuples,typeerror
I get a TypeError and I don't understand why. The error is at c = t[i][0] (according to the debugger). I have 3 char groups(lists): g1, g2 and g3 and I'm trying to change the char's index by substracting the key's k1, k2 or k3 from the index. What I'm...

Javascript: document.body.appendchild has a null value

javascript,jquery,html,iframe,typeerror
I am loading a .js file I wrote. Within that .js file I am creating a Iframe like this var frmSource = "http://MYLINK.com/mypage.php?" + encodeURI(URLBuilder); ifrm = document.createElement("IFRAME"); ifrm.setAttribute("src", frmSource);a ifrm.style.width = 0+"px"; ifrm.style.height = 0+"px"; ifrm.setAttribute("frameBorder", "0"); document.body.appendChild(ifrm); URLBuilder contains the GET variables to the next page The issue...

TypeError: unsupported operand type(s) for -: 'float' and 'method'

python,typeerror
So guys, I'm trying to work some exercises in Python after reading about classes and objects, and one of said exercises is to create an Account Class and write methods to withdraw and deposit money into an account. Every time I run it, I get a TypeError telling me that...

pytest error (newbie to pytest and TDD)

python,linux,module,typeerror,py.test
I'm having an issue trying to test the length of an instance's variable. I keep getting this error: ________________________________________ ERROR collecting test_Person.py _________________________________________ test_Person.py:7: in <module> person1 = Person("Tara", "Manderson", "F") E TypeError: 'module' object is not callable ------------------------------------------------ Captured stdout ------------------------------------------------- gender is: F last name is: Manderson first...

TypeError when ordering table data in Python

python,html,python-2.7,xpath,typeerror
I'm trying to read table data from Yahoo Finance with Python 2.7 and have it give me a 2-dimensional list of all the data. Here's my code so far: def getStocks(): from lxml import html import requests page = requests.get("https://finance.yahoo.com/q/op?s=INTC+Options") tree = html.fromstring(page.text) output = [["Strike"]["Contract Name"]["Last"]["Bid"]["Ask"]["Change"]["\% Change"]["Volume"]["Open Interest"]["Implied Volatility"]]...

TypeError: 'int' object is not iterable Python issues with loops (beginner)

python,typeerror
Ignoring any current issues with avsterr, I want to call the defined function avsterr to run x amount of times where x is length of my list(). barcodeCounter defines the max length of the list. I am not sure how to write the syntax and what type of loop I...

TypeError: '_io.TextIOWrapper' object is not subscriptable

python,python-2.7,python-3.x,typeerror
Getting the error as the title says. Here is the traceback. I know lst[x] is causing this problem but not too sure how to solve this one. I've searched google + stackoverflow already but did not get the solution I am looking for. Traceback (most recent call last): File "C:/Users/honte_000/PycharmProjects/Comp...

Copying CSV File when integer exceeds maximum

python,python-2.7,csv,typeerror
If this input exists in a specific row, for example DD in row WORD4 (row 3), the program will then ask them to enter an integer and if this is over a certain number it will write it including the line. Something like so: a0,a1,a2,a3,a4 JA,BV,PA,DD,6 The error received I...

Calling goodness of fit value with result.prsquared() in statsmodels results TypeError: 'numpy.float64' object is not callable

python,object,typeerror,result,statsmodels
I am a complete beginner, and I'm currently doing this tutorial about logit regression models in python 3.4, with statsmodels 0.6.1 and Pycharm community version 4.5.1: http://blog.yhathq.com/posts/logistic-regression-and-python.html It runs smoothly. I try to add my own lines, to try out a few things. After the part when I fit the...

TypeError: Undefined is not a function - Sails.js

javascript,node.js,sails.js,typeerror
So I'm currently learning Sails.js through following some tutorials and I have encountered this problem many times now. I tried searching for the solutions but none of them seemed to work. module.exports = { signup: function(req, res) { var username = req.param("username"); var password = req.param("password"); Users.findByUsername(username).done(function(err, usr){ if (err)...

Weird behaviour with len and str.splitlines()

python,string,typeerror,python-3.4
I'm making a HTTP request with the requests library and I want to make a Simple Response Object that parses my data. The problem I'm having is the following. When passing the response object to my ApiResponse I split the Response.text in lines, to count them and know if it...

Accessing Javascript/Google Apps Script properties via Object.keys TypeError

javascript,properties,google-apps-script,typeerror
I'm trying to write a generic script to loop thru an array of objects and return the values of the properties at each cycle. Rather than access the properties via myArray[0].someProperty; myArray[0].anotherProperty; I'm storing property names in an array using Object.keys(myArray[0]). However at runtime I get TypeErrors. Could anyone tell...

Tkinter Reddit scraper (Tkinter and Praw) returns error “TypeError”

python,tkinter,typeerror,reddit,scraper
Im relatively new to python and am trying to create a tkinter application that collects information from a specific subreddit and returns it back to the user in a tkinter window. However, when I run the code it returns the error: TypeError: 'NoneType' object has no attribute 'getitem' There appears...

How do I get rid of the NameError and TypeError

python,class,python-3.x,typeerror,nameerror
I keep getting an error of NameError: name animal_type is not defined or TypeError: __init__() missing 2 required positional arguments: 'animal_type' and 'name' no matter if I change the line to animal = Animal.Animal(animal_type, animal) or animal = Animal.Animal() and it has this later: #Add animal to list def addAnimal(animal):...

Python: datetime.date “expected datetime, got int”

python,datetime,typeerror
So, for a long time now, I have been using code like the following in Python for version tracking: ... import datetime ... """ Version tracking """ __version__ = 4.0 __dateV__ = datetime.date(2015, 5, 7) ... Now, out of the blue, I get an error saying "TypeError: descriptor 'date' requires...

Handling TypeError: 'NoneType' in BeautifulSoup

python,exception,beautifulsoup,typeerror
I am scraping a webpage with BeautifulSoup and the line where I look for a csrf token sometimes throws a TypeError. Code is: csrf = soup.find(id="csrfToken-postModuleForm")['value'] The error returned is: TypeError: 'NoneType' object has no attribute '__getitem__' I am looking to just continue with the script if that value does...

Histograms: “TypeError, list indices must be integers, not str”

python,list,histogram,typeerror,indices
I am trying to make a function that will take a character and a histogram and add an instance of that character to the histogram. My code so far is like this: def add_to_hist(character, histogram): """Takes a character and a histogram and adds an occurrence of that character to the...

Formidable and Node.js TypeError: Cannot read property 'path' of undefined

node.js,typeerror,formidable
If you're reading this, you're probably following Manuel Kiessling's Node tutorial. I was receiving the following error when completing the file upload part of the tutorial. fs.rename(files.upload.path, "img/img.jpg", function(error) { ^ TypeError: Cannot read property 'path' of undefined I searched around, found this and this, but they were pretty inconclusive...

F# strange type error message

types,f#,typeerror,discriminated-union
Can anyone tell me what the following error message means in F#: Program.fs(1021,16): error FS0001: This expression was expected to have type FSI_0051.ExprTree but here has type FSI_0061.ExprTree It was the result of executing the following function: let evaluate_tree tree = let rec helper tree = match tree with |...

Python: Opening a file with defined drive letter - TypeError: an integer is required

python,integer,typeerror,required
Here is my two lines of code: drive = 'j:' f = open("%s\sample", "wb", drive) I'm trying to write a simple program that is writing to a file that is being created by the program, the file is to be created on a defined drive, in this case, just onto...

xlrd throws TypeError: embedded NUL character when trying to open an `.xls` file from web in Python 3.4

python,python-3.x,typeerror,urllib,xlrd
I am trying to open an excel file from the web and extract one of the columns. However, when I try to open the file with xlrd I get an error. The code I am trying is: from urllib.request import urlopen import xlrd DJIA_URL = 'http://www.djaverages.com/?go=export-components&symbol=DJI' xlfile = urlopen(DJIA_URL).read() xlbook...

Scikit-learn TypeError: If no scoring is specified, the estimator passed should have a 'score' method

python,python-2.7,scikit-learn,typeerror,cross-validation
I have created a custom model in python using scikit-learn, and I want to use cross validation. The class for the model is defined as follows: class MultiLabelEnsemble: ''' MultiLabelEnsemble(predictorInstance, balance=False) Like OneVsRestClassifier: Wrapping class to train multiple models when several objectives are given as target values. Its predictor may...

TypeError: 'NoneType' object is not iterable when calling keys function

function,return,typeerror,iterable,nonetype
I am getting the error xShift, yShift = Manager.movementKeys(self, xShift, yShift) TypeError: 'NoneType' object is not iterable when I run my code and I can't figure out why. I don't shouldn't be getting any returns as None and none of my arguments are None. I apologize for any indentation errors....

Uncaught TypeError: X[g].exec is not a function fb tokenize

angularjs,twitter-bootstrap,angular-ui-bootstrap,typeerror,toastr
Since today I am getting an error as follows: Uncaught TypeError: X[g].exec is not a function fb tokenize This is the stack trace: Uncaught TypeError: X[g].exec is not a function fb.tokenize @ jquery.min.js:2 fb.compile @ jquery.min.js:2 fb.select @ jquery.min.js:2 fb @ jquery.min.js:2 m.event.handlers @ jquery.min.js:3 m.event.dispatch @ jquery.min.js:3 r.handle @...

Python TypeError: an integer is required while working with Sockets

python,sockets,integer,typeerror,required
Research: Getting a "TypeError: an integer is required" in my script https://github.com/faucamp/python-gsmmodem/issues/39 https://docs.python.org/2/howto/sockets.html Here is my complete error output: Traceback (most recent call last): File "/home/promitheas/Desktop/virus/socket1/socket1.py", line 20, in <module> createSocket() File "/home/promitheas/Desktop/virus/socket1/socket1.py", line 15, in createSocket ServerSock.bind((socket.gethostname(), servPort)) File "/usr/lib/python2.7/socket.py", line 224, in meth return...

Why am I getting this error? Uncaught TypeError: state.removeFlag is not a function

javascript,object,methods,typeerror,bitwise-operators
Problem Uncaught TypeError: state.removeFlag is not a function Extra Information I'm having trouble with the code below, giving me the error above. My intention is simple, I want to set up two functions in a 'class' then call them, but I am getting the above error and I can't spot...

If string is in another list, call on the next value in said list (Python 3)

python,python-3.x,typeerror
Let's say I have a value callfunc in list list1 that I want to call on the next value in the list, but only if callfunc is in list2 (it is). I have this code: for instr in list1: if instr in list2: eval(instr(list1[list1.index(instr)+1])) And I get this error message:...

TypeError when trying to call National Rail SOAP API via Node

xml,node.js,soap,typeerror,node-soap
I'm trying to access the National Rail API using node-soap. Documentation is here: https://lite.realtime.nationalrail.co.uk/OpenLDBWS/ I am new to SOAP so this might not be an issue with the API. I am getting a TypeError with whatever I attempt... TypeError: Cannot read property 'Body' of undefined Here is the code I...

JavaScript throws TypeError saying that my variable is undefined

javascript,html,typeerror
I don't have much experience in JavaScript, so far I have this: function loop() { var authorDivs = document.getElementById('ctl00_MainContent_MCPObjectInfo_dvCreatorView').getElementsByTagName("div"); for (var i = 0; i < authorDivs.length; i++) { var divOfDiv = authorDivs[i].getElementsByTagName("div"); if (typeof divOfDiv.item(i) === 'undefined' || divOfDiv.item(i) === null) { console.log("This is undefined or null"); } else...

Array cannot be coerced into Fixnum (TypeError)

ruby,typeerror
I have written a basic program of calculations. The program runs fine for some input, while gives TypeError for others. I can't figure out the reason behind this unpredictable behavior. Here's my code - class Conversion I = 1, V = 5, X = 10, L = 50, C =...

Scrolling marquee Uncaught TypeError: Cannot read property 'style' of undefined

javascript,typeerror
So Im keep coming up with typeError: Cannot read property 'style' undefined. It situated on the last line of javascript. Anyone any suggestions. The finished piece is to be a marquee with vertically scrolling text. window.onload = defineMarquee; var timeID; var marqueeTxt = new Array(); var marqueeOff = true; /*...

Python: Separating different parts of a string into an array

python,list,typeerror
I'm trying to separate values (in between the commas) in a string into an list. This is what I have so far: x = ["1,2,3,4,5,", "6,7,8,9,10,"] x_new = [] for j_1 in range(len(x)): y = 0 for j_2 in range(0, len(x[j_1])): if x[j_1][j_2] == ",": x_new.append(j_1, (x[j_1][y: j_2])) y =...

Python 3.4.2 - Socket module is not callable

python,sockets,typeerror
from socket import * import _thread from My_TCP_callable import * IP_list = [] port_list = [] def IP_find(IP_list): IPtarget = input("Enter host to scan: ") IP_list = [] print ('Starting scan on host ', IPtarget) for ip in range(1, 256): s = socket(AF_INET, SOCK_STREAM) addr = IPtarget + str(ip) result...

how to fix error 1009 in as3

actionscript-3,timer,typeerror
hi i have been searhing the net for hours and have not found a solution to my problem and i have no idea how to fix it as i am only new to flash so if you know anything that might help me just comment below please all help is...

python type error: does not support indexing

python,typeerror
import simplegui import random top=52 in_play=False suits=('C','S','H','D') ranks=('A','2','3','4','5','6','7','8','9','T','J','Q','K') alist=range(0,52) def deal(): global outcome,in_play,alist,top if not in_play: alist=range(0,52) in_play=True r = random.randint(0,top) card=Card(suits[alist[r]//13],ranks[alist[r]//4]) #line 73 alist=alist.remove(alist[r]) top=top-1 return card class Card: def __init__(self,suit,rank): global suits,ranks if (suit in suits) and (rank in ranks): self.suit=suit self.rank=rank else: self.suite=None...

typeerror:not all arguments converted during string formatting [closed]

python,tkinter,typeerror
i've been writing this program for encryption of messages by ceasar's method, but i have a major problem with this error. it is supposed to change the string b into c and c has to be encrypted. however nothing shows up in tkinter.i have seen several similar question regarding this...

TypeError: unsupported operand type in Python

python,typeerror
'Homework' Question in Python Book: Write a program that prompts the user to enter 3 points of a triangle angle and display its area, using the equations given: s = (side1 + side2 + side3) / 2 area = √s(s - side1)(s - side2)(s - side3) The program I wrote...

Cant get rid of this type Error

javascript,typeerror
Heys Guys.... Im having trouble getting rid of a type error on the 4th line of this code. Any suggestions...??? function update() { var numRegExp = /^\d*(\.\d{0,2})?$/; if (numRegExp.test(this.value) !== false){ (this.value).toFixed(2); for (var i = 1; i < 4; i++) { document.forms[0].elements["sub" + i].value = calcRow(i).toFixed(2); document.forms[0].total.value = calcTotal().toFixed(2);...

TypeError: string indices must be integers, not str on Python Dictionary

python,for-loop,dictionary,typeerror
I'm stuck, on what I'm sure is something simple, but I'm just going around in circles now. The following code is a snippet of a script that iterates over some values I've entered into lists and dictionaries and produces text files that I can feed into another program. The problem...

javascript wont work because variable from other page is null (TypeError)

javascript,typeerror
This function works on page1 The console says TypeError: lightbox (from function below) is null lightbox is on page2 function setBackgroundImg() { var windowHeight = window.innerHeight; var bgImg = document.getElementById("kr-home-bg"); var x = windowHeight + "px"; bgImg.setAttribute("style","height:" + x); // line in question when page2 loads } setBackgroundImg(); window.addEventListener("resize",...

Tkinter button callback missing an argument that it contains [duplicate]

python,tkinter,loading,typeerror
This question already has an answer here: How to pass arguments to a Button command in Tkinter? 4 answers In an attempt to make a program that takes a username and password given by the user and then loads that document, I've encountered an odd error load_user() missing 1...

TypeError: number is not a function

javascript,function,typeerror
I'm developing a text-based game, and I have a function (turn()) that determines the user's action based on what button they press. But every time you press one of the 3 buttons, the console says TypeError: number is not a function. I've tried many operations (such as moving all of...

Python TypeError on calculator that I'm creating

python,typeerror
As part of my 'teach yourself python', I am currently creating a GUI calculator. So far I have the interface up and running. And one operation is functional, however, when I reuse the calculator (without restarting the app) I get a "TypeError: 'str' object is not callable", which suggests I...

Why do I get loose closing brackets for my Django Rest Framework endpoint?

json,django,django-rest-framework,typeerror
Here's my JSON response for http://localhost:8000/characters/api/users/1?format=json )]}', {"id":1,"username":"admin","mage_by_user":[3],"mage_last_updated":"2015-02-11T16:13:16.229Z"} Notice the )]}', on the first line. Here is my code that gets called to create the JSON: class UserSerializer(serializers.ModelSerializer): mage_by_user = serializers.PrimaryKeyRelatedField( many=True, queryset=Mage.objects.all()) mage_last_updated = serializers.ReadOnlyField( source='mage_by_user.updated_date') class Meta: model = User fields = ('id',...

Pass an array in python odeint

python,arrays,typeerror,odeint
I am quite new to Python, so do excuse me if the following question has a 'duh' answer. So, I'm trying to solve an ODE using odeint and wish to pass an array. But, the TypeError: can't multiply sequence by non-int of type 'float' keeps cropping up, in the line:...

while executing loop the error is list indices must be intergers,not tuple

list,numpy,typeerror,lis
I want to store all the iteration output in a matrix(of size 200x200). While executing the code : got the error at the for t in (T2/Taw)*np.arange(-Taw,Taw-1): i=i+1; j=0; for Fd in (B/Taw)*np.arange(-Taw,Taw-1): j=j+1; val1=1-abs(t)/T2; val2=pi*T2*val1; val3=Fd+mu*t+np.spacing(1); val4=val2*val3; ambg[j,i]=np.abs(val1*(sin(val4)/(val4)))**2; ---> 62 ambg[j,i]=np.abs(val1*(sin(val4)/(val4)))**2; TypeError: list indices must be integers, not tuple...

Casper JS: TypeError: 'null' is not an object

javascript,null,phantomjs,typeerror,casperjs
I am trying to grab the "David Welsh" text on this page: http://foster.uw.edu/faculty-research/directory/david-welsh/ When I do document.getElementById('Boundless').children[0].children[2].children[0].children[1].children[0].innerHTML in the browser console, I successfully select the text I want, but when I run my js file in Terminal, I get the error: TypeError: 'null' is not an object (evaluating 'document.getElementById('Boundless').children') Why...

Reference to Object.prototype.toString.call resulting in 'TypeError: undefined is not a function'

javascript,reference,prototype,this,typeerror
I'm encountering an unusual situation. I store a reference to Object.prototype.toString.call, in an attempt to make a shortcut, calling it as the assigned variable results in a TypeError, whereas calling it directly each time does not. Can anyone explain what is actually happening, as opposed to what I believe I...

Error when running argument script from textbook

python,typeerror,traceback
I have a beginners coding class for Python. The book we are using is "Coding for Penetration Testers Building Better Tools". During out second chapter we started to create Python scripts and I cannot seem to figure out what is wrong with this script I am supposed to retype from...

TypeError: Factory.function is not a function

javascript,angularjs,factory,typeerror
I am writing my first angular application with a web api and I am having some problems with calling functions from a factory. I have two factories that looks like this: main.factory('Table', function ($http, $log) { return { build: function (token, cubeid) { return $http({ method: 'POST', url: 'http://localhost:50051/api/structure/cube', headers:...

TypeError: 'int' object is not iterable using max()

python,arrays,recursion,max,typeerror
I am trying to get the maximum between some ints using the Python max() function. However, I get this TypeError: 'int' object is not iterable. This is my code: def main(): inputs =[] inputted = int(raw_input()) inputs.append(inputted) for i in range(0,inputs[0]): inputted = int(raw_input()) inputs.append(inputted) total = valor_max(inputs[1::], 0, len(inputs)-1)...

Python TypeError: draw() takes exactly 1 argument (2 given) [duplicate]

python,pygame,typeerror
This question already has an answer here: Interesting 'takes exactly 1 argument (2 given)' Python error 6 answers I am trying to make an image appear on the pygame screen but I keep getting the error: TypeError: draw() takes exactly 1 argument (2 given) when I run the 2nd...

Type Error when Comparing Two Dictionaries Using Cosine Similarity in Python

python,dictionary,typeerror,cosine-similarity
I have received a type error while comparing two dictionaries using the cosine similarity. I have tried to search around but still not able to solve it, and would really appreciate if anyone could shed some light for me. My dictionaries look as like below. dict1 = {'a': 1, 'b':...

Missing 1 potential argument

python,python-3.x,typeerror
this is my first post on this website, i'm taking an online course for intro to programming and it's pretty tough for an intro. I have no previous experience with coding and python is the first language i'm learning so please forgive me if I'm doing something wrong on the...

Uncaught TypeError: Cannot read property 'company_id' of undefined [closed]

javascript,arrays,ajax,typeerror
I'm getting this error from my script, weird thing is, it still works. It still runs and changes the values just fine. Uncaught TypeError: Cannot read property 'company_id' of undefine. Here's my code: for(i=0; i<=getUsersCount; i++){ var user = null; var uCompany = null; if(getUsers.data[i].company_id === null) uCompany = "Trego";...

TypeError: coercing to Unicode: need string or buffer, file found (open() function)

python,unicode,typeerror
I'm new to programing especially Python. I'm trying to learn it with this tutorial . I'm at exercise 19 now and one of the study drills is to create my own function of my own design and run it ten different times. I think I did well so far until...