ypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType' - xlwings

I have error if trying to do example
http://docs.xlwings.org/en/stable/vba.html
---------------------------
Error
---------------------------
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Python3\mymodule.py", line 7, in rand_numbers
n = int(Range('Sheet1', 'B1').value) # Write desired dimensions into Cell B1
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
Press Ctrl+C to copy this message to the clipboard.
---------------------------
OK
---------------------------

I suggest the error occurred due to absence value in the cell. Try to check if the value is None before conversion to int.

Related

Attribute Error: 'list' object has no attribute 'lower' problem

I am writing code for AI chatbot in which I have to lemmatize words of data corpus
word_patterns = [lemmatizer.lemmatize(word.lower()) for word in word_patterns]
but it gives error like
Traceback (most recent call last):
word_patterns = [lemmatizer.lemmatize(word.lower()) for word in word_patterns]
AttributeError: 'list' object has no attribute 'lower'
How do I solve it??
I have no idea to resolve it

Why my syntax is error? (TypeError: 'tuple' object is not callable)

My syntax is like this
print ("Hello!")
print ("Ayah berkata, \"Semangat\"")
print ("Ayah berkata,", end=" ")
print ("\"Semangat\"")
and my output is like this
TypeError Traceback (most recent call last)
<ipython-input-8-122075a697db> in <module>()
----> 1 print ("Hello!")
2 print ("Ayah berkata, \"Semangat\"")
3 print ("Ayah berkata,", end=" ")
4 print ("\"Semangat\"")
TypeError: 'tuple' object is not callable
I'm code at google colab
You have created a variable named "print" which is a tuple. You have to remove or rename the variable "print".
>>> print = ("test", "test") # <- somewhere there might be a linge likethis one
>>> print ("Anything")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'tuple' object is not callable

Why isdigit is working but isdecimal is not for a simple age code

This is the part of code I am talking about:
while True:
print 'What is your age(only numeric):'
age = raw_input()
if age.isdigit():
break
print 'Please try again. We take only numeric value.'
When I replace isdigit with isdecimal, I get this error no matter what value i enter.
Traceback (most recent call last):
File "test.py", line 4, in <module>
if age.isdecimal():
AttributeError: 'str' object has no attribute 'isdecimal'
Although it runs fine with isdigit.
Also, when I replace raw_input with input, it give this error.
Traceback (most recent call last):
File "test.py", line 4, in <module>
if age.isdigit():
AttributeError: 'int' object has no attribute 'isdigit'
Am I doing something wrong which I am not able to catch? I am new to python and did my research about isdigit, is decimal, input and raw_input before putting down question here. It may be very minute error but I am not sure what is it.
For the first part:
In Python 2, isdecimal is a method of the unicode class, not of str (i.e. bytes). Hence:
>>> '3.2'.isdecimal()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'str' object has no attribute 'isdecimal'
>>> u'3.2'.isdecimal()
For the second part, input tries to guess what kind of input it gets, and will properly cast "1" into an int, while raw_input will always return the raw string. Since isdigit is a method defined in the str class, you get the error.

Unable to Restore the Backup File in PgAdmin4

I have been using "PgAdmin 4" and i am unable to restore the backup file. it gives me an error
"object of type 'bool' has no len() pgadmin restore"
My Log file detail is given below :
"2018-08-01 11:06:38,943: ERROR pgadmin: object of type 'bool' has no len()
Traceback (most recent call last):
File "C:\Program Files\PostgreSQL\10\pgAdmin 4\web\pgadmin\tools\restore\__init__.py", line 327, in create_restore_job
*args
File "C:\Program Files\PostgreSQL\10\pgAdmin 4\web\pgadmin\tools\restore\__init__.py", line 84, in __init__
if arg and len(arg) >= 2 and arg[:2] == '--':
TypeError: object of type 'bool' has no len()
2018-08-01 11:08:58,861: ERROR pgadmin: object of type 'bool' has no len()
Traceback (most recent call last):
File "C:\Program Files\PostgreSQL\10\pgAdmin 4\web\pgadmin\tools\restore\__init__.py", line 327, in create_restore_job
*args
File "C:\Program Files\PostgreSQL\10\pgAdmin 4\web\pgadmin\tools\restore\__init__.py", line 84, in __init__
if arg and len(arg) >= 2 and arg[:2] == '--':
TypeError: object of type 'bool' has no len() "
Thanks
I had the same problem when I tried to restore a TAR file created by own pg Admin. To solve this problem I needed to rename the file with a ".tar" in the end of file (example: my-backup.tar).
I though this very strange, in spite of himself had generated the file.

python3 'Nontype object' is not subscriptable

How can I solve this problem?
def median(lst):
lst_s=lst.sort()
k=len(lst)
if k%2==0:
return ((lst_s[k/2]+lst_s[k/2-1])/2)
elif k%2==1:
return (lst_s[k/2-1/2])
res = median([1,2,3,7,6,5])
print('median:',res)
when I run this, it says
Traceback (most recent call last):
File "E:\lab5_p4_2015123176.py", line 13, in <module>
res = median([1,2,3,7,6,5])
File "E:\lab5_p4_2015123176.py", line 7, in median
return ((lst_s[k/2]+lst_s[k/2-1])/2)
TypeError: 'NoneType' object is not subscriptable
The problem is that list.sort() sorts the items of the list in place thus returns None. In your median function you need to replace lst_s = lst.sort() by lst_s = sorted(lst) if you don't want to modify element order in the original list.