Questions tagged [typeerror]

A TypeError is a specific type of error raised when an operation or function is applied to an object of inappropriate type. You might encounter it in Python or JavaScript.

A TypeError often occurs during operations on two data types.

An example is given below, in which an attempt is made to add an integer to a string:

>>> 3 + "string"
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'int' and 'str'
>>>

Note that this behavior is not universal; some languages do not require two of the same data type to perform operations.

5623 questions
54
votes
2 answers

What does this error mean — Uncaught TypeError: Already read?

In Javascript, when is this error thrown? index.js /** * Created by tushar.mathur on 24/12/15. */ 'use strict' const _ = require('lodash') const Rx = require('rx') const createDataStore = require('./src/createDataStore') const fetch = x =>…
tusharmath
  • 9,120
  • 11
  • 52
  • 70
52
votes
7 answers

Uncaught TypeError: Cannot read property 'value' of undefined

I have some JavaScript code that gives this error Uncaught TypeError: Cannot read property 'value' of undefined Code var i1 = document.getElementById('i1'); var i2 = document.getElementById('i2'); var __i = {'user' :…
John
  • 6,080
  • 14
  • 58
  • 91
51
votes
6 answers

Python TypeError on regex

So, I have this code: url = 'http://google.com' linkregex = re.compile('') m = urllib.request.urlopen(url) msg = m.read() links = linkregex.findall(msg) But then python returns this error: links =…
kamikaze_pilot
  • 12,874
  • 29
  • 103
  • 169
50
votes
13 answers

OpenCV TypeError: Expected cv::UMat for argument 'src' - What is this?

Disclaimer: huge openCV noob Traceback (most recent call last): File "lanes2.py", line 22, in canny = canny(lane_image) File "lanes2.py", line 5, in canny gray = cv2.cvtColor(imgUMat, cv2.COLOR_RGB2GRAY) TypeError: Expected cv::UMat for argument…
autonocat
  • 537
  • 1
  • 4
  • 7
50
votes
1 answer

pandas comparison raises TypeError: cannot compare a dtyped [float64] array with a scalar of type [bool]

I have the following structure to my dataFrame: Index: 1008 entries, Trial1.0 to Trial3.84 Data columns (total 5 columns): CHUNK_NAME 1008 non-null values LAMBDA 1008 non-null values BETA …
anonuser0428
  • 8,987
  • 18
  • 55
  • 81
50
votes
3 answers

TypeError:exceptions must be old-style classes or derived from BaseException, not str

Following is my code: test = 'abc' if True: raise test + 'def' And when i run this, it gives me the TypeError TypeError: exceptions must be old-style classes or derived from BaseException, not str So what kind of type should the test be?
2342G456DI8
  • 1,729
  • 2
  • 14
  • 29
48
votes
3 answers

json.dump throwing "TypeError: {...} is not JSON serializable" on seemingly valid object?

Background: I am writing a python program which should manage my music files. It crawls directories and puts the files and their meta data (via mutagen), encoded in JSON, in a file as a simple "database". I have the directory searching fine, but…
drdrez
  • 871
  • 1
  • 7
  • 14
47
votes
4 answers

I keep getting this error for my simple python program: "TypeError: 'float' object cannot be interpreted as an integer"

I don't understand why I can't use my variable c. code: from turtle import * speed(0) hideturtle() c = 450 def grid(x,y,a): seth(0) pu() goto(x,y) pd() for i in range(4): forward(a) rt(90) for i in…
remorath
  • 573
  • 1
  • 4
  • 7
42
votes
2 answers

My javascript is returning this error: $.ajax is not a function

Not sure what's wrong but I'm getting this error from my chrome console: jquery-3.2.1.slim.min.js:1244 jQuery.Deferred exception: $.ajax is not a function TypeError: $.ajax is not a function at HTMLDocument.
Adamwuh
  • 443
  • 1
  • 4
  • 5
42
votes
16 answers

Slick Carousel Uncaught TypeError: $(...).slick is not a function

Somehow I'm unable to use slick carousel (http://kenwheeler.github.io/slick/) correctly. I'm getting the following error: Uncaught TypeError: $(...).slick is not a function I'm running the following code in my javascript file: function…
Sanderfish
  • 1,200
  • 1
  • 10
  • 14
42
votes
3 answers

Python3 Error: TypeError: Can't convert 'bytes' object to str implicitly

I am working on exercise 41 in learnpythonthehardway and keep getting the error: Traceback (most recent call last): File ".\url.py", line 72, in question, answer = convert(snippet, phrase) File ".\url.py", line 50, in convert …
thewooster
  • 705
  • 1
  • 6
  • 19
39
votes
3 answers

TypeError: sequence item 0: expected str instance, bytes found

for line in fo: line = " ".join(line.split()) line = line.strip() I am getting an error line = ''.join(line.split()) TypeError: sequence item 0: expected str instance, bytes found its working fine in python 2.x, but not working on…
Muhammad Umer
  • 583
  • 2
  • 5
  • 11
37
votes
9 answers

TypeError: 'list' object cannot be interpreted as an integer

The playSound function is taking a list of integers, and is going to play a sound for every different number. So if one of the numbers in the list is 1, 1 has a designated sound that it will play. def userNum(iterations): myList = [] for i in…
Greysus
  • 425
  • 1
  • 4
  • 9
36
votes
10 answers

Uncaught TypeError: Object # has no method 'movingBoxes'
Im trying to use the movingBoxes plugin with my asp.net mvc site and it is not working (obviously). I have the movingboxes.js imported in my head tag in the site.master like so