'str' object has no attribute 'h264' - performance

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'

Related

Anyone familiar with KeyError: 'v5' while using gekko

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.

'Error compiling Cython file error' from one day to another

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.

UnicodeDecodeError in pickle.load

I'm having some problems with loading a pkl file using pickle. I'm using windows 7 and Python 3.5.1 64 bit. The pkl file was downloaded from here.
This is my code:
import pickle
# Load model weights and metadata
weightFile = open('vgg16.pkl', 'rb')
d = pickle.load(weightFile)
and when I run it I get the output
"C:\Program Files\Python35\python.exe" C:/work/lasagne/tutorial/lasagne-tutorial2.py
Traceback (most recent call last):
File "C:/work/lasagne/tutorial/lasagne-tutorial2.py", line 5, in <module>
d = pickle.load(weightFile)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xbc in position 1: ordinal not in range(128)
Process finished with exit code 1
What does this error message mean? It says that there is a byte that the acsii codec can't decode, but isn't a pkl file supposed to be binary (hence not contain ascii characters)?
Am I doing something wrong when loading the file? What can I do to fix the error?
The solution was found in this answer. The pickle file was probably encoded with Python 2, and providing pickle.load with the optional argument encoding='latin1' solved the problem.
The code that works looks like this:
import pickle
# Load model weights and metadata
weightFile = open('vgg16.pkl', 'rb')
d = pickle.load(weightFile, encoding='latin1')

tkinter.TclError: invalid command name ".52674064

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.

XCode: iOS5 localization script - Exit code 1

i'm using the popular pythonscript ( http://code.google.com/p/edim-mobile/source/browse/trunk/ios/IncrementalLocalization/localize.py ) to localize my storyboards in ios5.
I did only some changes in storyboard and got this error:
Please file a bug at http://bugreport.apple.com with this warning
message and any useful information you can provide.
com.apple.ibtool.errors
description The strings
file "MainStoryboard.strings" could not be applied.
recovery-suggestion Missing object referenced
from oid-keyed mapping. Object ID ztT-UO-myJ
underlying-errors
description
The strings file "MainStoryboard.strings" could not be applied.
recovery-suggestion
Missing object referenced from oid-keyed mapping. Object ID ztT-UO-myJ
Traceback (most recent call last): File "./localize.py", line 105, in
raise Exception("\n" + errorDescription) Exception:
* Error while creating the 'Project/en.lproj/MainStoryboard.storyboard' file*
* Error while creating the 'Project/es.lproj/MainStoryboard.storyboard' file*
* Error while creating the 'Project/fr.lproj/MainStoryboard.storyboard' file*
* Error while creating the 'Project/it.lproj/MainStoryboard.storyboard' file*
Showing first 200 notices only Command /bin/sh failed with exit code 1
I can't find a solution..
Maik
I think when you made the changes to the storyboard, you removed an Interface Builder object from the storyboard with the ID ztT-UO-myJ. Hence the error message shown.
Try to search for that ID in MainStoryboard.strings file and remove the whole line. After that try again to run the script.
If ibtool fails with
Interface Builder could not open the document NAME.storyboard because
it does not exist
Execute this in terminal:
killall -9 ibtoold
Found at:
http://oleb.net/blog/2013/02/automating-strings-extraction-from-storyboards-for-localization/
P.S. The link contains a better script. https://github.com/ole/Storyboard-Strings-Extraction
P.S. This answer has links to articles about may be even better scripts

Resources