P4PYTHON : 'str' object has no attribute '_description' - python-2.7

from P4 import P4, P4Exception
p4 = P4()
p4.connect()
change = p4.fetch_change()
change._description = "My changelist\nSubmitted from P4Python\n"
Error: Traceback (most recent call last):
File "", line 1, in
AttributeError: 'str' object has no attribute '_description'
how can i fix this please ?

No Problem, I fixed it.I was using an older version of P4PYTHON module

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

AttributeError: 'SolverStatus' object has no attribute 'key'

i got this error message when running an energy system optimization problem. Please any tips on how to resolve this?
Blockquote
"Traceback (most recent call last):
File "C:\Users\aadetunj\Desktop\oemof-examples-master\OSeEM-SN-main\scripting\scenarios\OSeEM-SN.py", line 318, in
m.solve("cbc")
File "C:\Users\aadetunj\Anaconda3\envs\virtualenv\lib\site-packages\oemof\solph\models.py", line 204, in solve
status = solver_results["Solver"][0]["Status"].key
AttributeError: 'SolverStatus' object has no attribute 'key'
Blockquote

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

from nltk.parse.corenlp import CoreNLPServer
server = CoreNLPServer()
server.start()
When I run the above code, I'm getting the following error.
Traceback (most recent call last):
File "server.py", line 30, in <module>
server.start()
File "/usr/local/lib/python2.7/dist-packages/nltk/parse/corenlp.py", line 130, in start
stderr=stderr,
File "/usr/local/lib/python2.7/dist-packages/nltk/internals.py", line 112, in java
subprocess_output_dict = {'pipe': subprocess.PIPE, 'stdout': subprocess.STDOUT, 'devnull': subprocess.DEVNULL}
AttributeError: 'module' object has no attribute 'DEVNULL'
subprocess.devnull is new in Python 3.3.
Make sure you use a version of nltk which stil supports Python 2.7. From their changelog:
Version 3.5 2019-10-16
* drop support for Python 2

Is there a reason `tolist()` can't operate on a list?

I often think it would be nice to have the following work even if the original object is a list... Is there a reason why this functionality is not implemented (in python 2.7)?
Example:
>>> a = [1,2,3,4]
>>> a.tolist()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'list' object has no attribute 'tolist'

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.