Anyone familiar with this error?
Traceback (most recent call last):
File "C:/Users/Geebug/Documents/ParameterEstimationGekko_v6.py", line 104, in <module>
m.solve()
File "C:\Users\Geebug\AppData\Local\Programs\Python\Python39\lib\site-packages\gekko\gekko.py", line 2227, in solve
self.load_JSON()
File "C:\Users\Geebug\AppData\Local\Programs\Python\Python39\lib\site-packages\gekko\gk_post_solve.py", line 70, in load_JSON
vp.__dict__[o] = data[vp.name][o]
KeyError: 'v5'
I am trying to solve a (parameter estimation) optimization problem in a loop using Gekko, such that the values of the parameter changes with every iteration and solves. The problem solve only the first two iterations and produces the above error message after the second iteration.
The KeyError is likely due a Gekko variable that is redefined as another Gekko variable so it no longer exists as an output. The error happens when the solution is returned to Python and loaded back into x.value after a solution is found.
Related
trying to do rasp. pi project "parent detector". fixed error with camera. now having an error i have 0 idea how to fix.
already had camera error fixed. old raspberry pi model. don't know what model. looked at project site and at answers and there shouldn't be an error.
entire error says:
filename= "{0:%Y}-{0:%m}-{0:%d}.h264
Attribute Error: 'str' object has no attribute 'h264'
this is the code for the project.
from gipiozero import MotionSensor
import picamera
from datetime import datetime
pir=MotionSensor(4)
while True:
filename= "{0:%Y}-{0:%m}-{0:%d}.h264
pir.wait_for_motion()
camera.start_recording(filename)
pir.wait_no_motion()
camera.stop_recording()
expected a motion detecting camera. got errors. gave up, teacher is forcing me to do this.
Regarding the line:
filename= "{0:%Y}-{0:%m}-{0:%d}.h264
you almost certainly should have a closing " at the end. However, given the error, I'm pretty certain what you actually have is something like:
filename= "{0:%Y}-{0:%m}-{0:%d}".h264
which would cause you to try and access the h264 property of that string:
>>> "{0:%Y}-{0:%m}-{0:%d}".h264
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'str' object has no attribute 'h264'
In addition, you are probably trying to construct a filename from a datetime object, and this can be done with:
>>> from datetime import datetime as dt
>>> "{0:%Y}-{0:%m}-{0:%d}.h264".format(dt.now())
'2019-06-11.h264'
I use a lot of special characters from Hun language, and there were no problems previously. Now they all give errors when running the whole script (F9). It still runs perfect when running locally (select + F5).
Fúú='bar'
Traceback:
C:\Users\my name\.ipython\cython\_cython_magic_21a3824690cdb52a9fe6a3fa1c63ee73.pyx:1:1: Unrecognized character
Traceback (most recent call last):
File "<ipython-input-6-dcfab52d0ff4>", line 1, in <module>
runfile('E:/Anyagok/Programozas/Python/projekts/elo/mindennap/untitled0.pyx', wdir='E:/Anyagok/Programozas/Python/projekts/elo/mindennap')
File "E:\Download\PROGIK\ANACONDA\lib\site-packages\spyder\utils\site\sitecustomize.py", line 703, in runfile
ipython_shell.run_cell_magic('cython', '', f.read())
File "E:\Download\PROGIK\ANACONDA\lib\site-packages\IPython\core\interactiveshell.py", line 2131, in run_cell_magic
result = fn(magic_arg_s, cell)
File "<decorator-gen-130>", line 2, in cython
File "E:\Download\PROGIK\ANACONDA\lib\site-packages\IPython\core\magic.py", line 187, in <lambda>
call = lambda f, *a, **k: f(*a, **k)
File "E:\Download\PROGIK\ANACONDA\lib\site-packages\Cython\Build\IpythonMagic.py", line 321, in cython
assert len(extensions) == 1
TypeError: object of type 'NoneType' has no len()
If I change to e.g.
Fuu='bar'
it works great. Why the sudden change of heart?
EDIT:
Have been messing around with FFMPEG and LIBAV yesterday, because wanted to download and convert Youtube videos to mp3. But I'm pretty sure I ran scripts with these characters succesfully after it.
I am trying to run a Tkinter GUI on Python 3.x and When I use the .get command to get the number off a scale, this error pops up
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python34\lib\tkinter\__init__.py", line 1482, in __call__
return self.func(*args)
File "C:\Users\Danny\Downloads\Space RPG. Alpha 0.2 (2) (1).py", line 39, in close
print (w1.get(), w2.get())
File "C:\Python34\lib\tkinter\__init__.py", line 2840, in get
value = self.tk.call(self._w, 'get')
_tkinter.TclError: invalid command name ".52674064"
What is happening?
That usually means that you're trying to call a method on a widget that has been destroyed. The string .52674064 is the internal name of a specific widget.
This can easily happen if you call a function via a binding or via after, if the widget is destroyed before the binding or after call has been triggered.
I'm trying to run my python code using sublimeREPL's "Python - RUN current file" command
It works fine if my program has no problems, but when it does, it doesn't show the complete Traceback (I don't get to see the "Repl Closed" message), and the output its not even consistent. Below two runs of the exactly same file (not posting images because stackoverflow doesn't allows me to because I'm new):
First Run:
------- Ford Fulkerson -------
Traceback (most recent call last):
File "Ford-Fulkerson.py", line 282, in <module>
D = FordFulkersonGeneral(G, ['A'], ['E'], None, restricciones)
File "Ford-Fulkerson.py", line 71, in FordFulk|
Second Run:
------- Ford Fulkerson -------
Traceback (most recent call last):
File "Ford-Fulkerson.py", line 282, in <module>
D = FordFulkersonGeneral(G, ['A'], ['E'
I was using the Anaconda's (64 bit) python distribution. Then I changed to a regular python (32 bit) install (made sure the window's path was all right) and even there its not working.
If I run my code from window's terminal I get the full Traceback (the actual error is not important, I know how to fix it):
------- Ford Fulkerson -------
Traceback (most recent call last):
File "Ford-Fulkerson.py", line 282, in <module>
D = FordFulkersonGeneral(G, ['A'], ['E'], None, restricciones)
File "Ford-Fulkerson.py", line 71, in FordFulkersonGeneral
G.deleteNode(v)
File "C:\Users\myusername\Documents\Learning\Anßlisis de Re
des\Ford-Fulkerson\mvr_graph.py", line 196, in deleteNode
self.nodes[node].delete(n)
AttributeError: 'dict' object has no attribute 'delete'
Edit:
I've found the answer by posting this question. The problem was in the path of the file - it contains an accent in the word "Análisis". I changed that and know its working.
It used to work when I had my OS language set to spanish. I set my new installation to english and now it was giving me trouble. I really didn't expected that, shame on you Windows x(.
I don't really know the protocol, I will just leave this question here in case anyone is going through this obscure thing.
I've found the answer by posting this question. The problem was in the path of the file - it contains an accent in the word "Análisis". I changed that and know its working.
It used to work when I had my OS language set to spanish. I set my new installation to english and now it was giving me troubles. I really didn't expected that, shame on you Windows x(.
My test code is:
#!/usr/bin/env python
import win32com.client
def GetFolderSizeQuick(target_folder):
fso = win32com.client.Dispatch("Scripting.FileSystemObject")
fobj = fso.GetFolder(target_folder)
return fobj.size
print(GetFolderSizeQuick("d:/pytools"))
print(GetFolderSizeQuick("d:/cygwin"))
The result is:
D:\>python a.py
160659697
Traceback (most recent call last):
File "a.py", line 10, in <module>
print(GetFolderSizeQuick("d:/cygwin"))
File "a.py", line 7, in GetFolderSizeQuick
return fobj.size
File "D:\Applications\Python33\lib\site-packages\win32com\client\dynamic.py",
line 511, in __getattr__
ret = self._oleobj_.Invoke(retEntry.dispid,0,invoke_type,1)
pywintypes.com_error: (-2147352567, '发生意外。', (0, None, None, None, 0, -2146828218), None)
The first call GetFolderSizeQuick on d:/pytools folder works. it's about 153MB. But the second call failed. The folder d:/cygwin is about 12.6GB.
I am working on windows 7 with python3.3.0 32bit version. So I think the problem happened on the 32bit or 64bit to store the result. 32bit int can not store 12.6GB size.
What is the real problem here, and how to fix it?
That's neither a directory size nor a 32/64-Bit problem.
It's even not a python2 or python3 problem.
Your Error translates to "No Access allowed!"
The simpliest way for testing would be to create a directory where only the owner is allowed to read and all others have NO rights at all. Then take this directory as input - you'll get the same error, even if the directory is empty. A good example would be the local "c:\system Volume Information".
Digging a little deeper:
The errorcodes given by python are signed, whereas for a reasonable lookup Microsoft describes and expects them as unsigned. Kudos to EB in this thread and Tim Peters in this thread, using the examples, you'll get reasonable error-Codes.
import win32com.client
import pywintypes
def get_folder_size(target_folder):
fso = win32com.client.Dispatch("Scripting.FileSystemObject")
fobj = fso.GetFolder(target_folder)
return fobj.size
if __name__ == '__main__':
try:
get_folder_size('c:/system volume information')
except pywintypes.com_error, e:
print e # debug, have to see which indices
print hex(e[0]+2**32), hex(e[2][5]+2**32)
Now search for both of the hex digits, the 2nd one should lead to a lot of "you are not allowed to..." queries and answers.