When I run the code below in jupyter, it is excellent, I get the results I want.
real = fr.load_image_file("image.jpg")
unknown = fr.load_image_file("image2.jpg")
# encodings
real_encoding = fr.face_encodings(real)[0]
unk = fr.face_encodings(unknown)[0]
result = fr.compare_faces([real_encoding], unk)
print(result)
but when I copy and paste the same code to an editor(atom the one I am using), and then run it using command prompt, I get an error as shown below
Traceback (most recent call last):
File "face_recognizer.py", line 13, in <module>
real_encoding = fr.face_encodings(real)[0]
IndexError: list index out of range
I activated the environment in which I was running the cmd.
Can someone advise me where I maybe going wrong?
There was no face captured in the photo.
That is why it throws an exception.
Related
Running Manjaro stable with python-3.9 and python-fipy-3.4.2.1-1.
Just got started with FiPy, ultimately interested in writing single and two-phase flow code. Naturally I tried to run examples/flow/stokesCavity.py (stripped down from all rst text) with: python stokesCavity.py and it throws the following error:
Traceback (most recent call last):
File "/home/zbinkz/HGST/Projects/Python/fipy/examples/flow/stokesCavity.py", line 117, in <module>
viewer = Viewer(vars=(pressure, xVelocity, yVelocity, velocity),
File "/usr/lib/python3.9/site-packages/fipy/viewers/__init__.py", line 130, in Viewer
raise ImportError("Failed to import a viewer: %s" % str(errors))
ImportError: Failed to import a viewer: ["matplotlib: True is not a valid value for orientation; supported values are None, 'vertical', 'horizontal'", "mayavi: No module named 'enthought'"]
I tinkered with different values for FIPY_VIEWER in the viewer command at line 117 reported above but still get the same error. At this very early stage with FiPy I'm clueless, anybody know how to fix this?
Thanks :)
In this line, change
... viewer = Viewer(vars=(pressure, xVelocity, yVelocity, velocity),
... xmin=0., xmax=1., ymin=0., ymax=1., colorbar=True)
to
... viewer = Viewer(vars=(pressure, xVelocity, yVelocity, velocity),
... xmin=0., xmax=1., ymin=0., ymax=1., colorbar='vertical')
I've filed a ticket to correct this.
I have built a simple app with Blynk. Unfortunately, I regularly get the error:
Traceback (most recent call last):
File "/home/pi/Desktop/Blynk/blynktest2.py", line 12, in <module>
blynk.run()
File "/home/pi/.local/lib/python3.7/site-packages/BlynkLib.py", line 252, in run
self.process(data)
File "/home/pi/.local/lib/python3.7/site-packages/BlynkLib.py", line 213, in process
self.emit("int_"+args[1], args[2:])
IndexError: list index out of range
Even if I take out all code on my hardware and end up with the following code, the error comes up:
import BlynkLib
BLYNK_AUTH = 'MY_AUTH_IS_NORMALLY_HERE'
# initialize blynk
blynk = BlynkLib.Blynk(BLYNK_AUTH)
while True:
blynk.run()
I do not know exactly what causes the error, however, I noticed that the error occurs
when the Blynk app is moved to the background
when the screen of the mobile phone turns black
the eror does not occur when normal disconnecting in the Blynk app via the stop button in the top right, and also not if reconnecting then
This is one random issue which keeps happening. Try recreating the project by removing all the controllers or create a new project and update the authentication code in your code.
When I 'print' some hex string, some interesting error information in python, I wonder why this error is caused.
Win10(I tried it on ubuntu, No ERROR),python 2.7
enc_hex = '''f982f01c'''
enc_ascii = enc_hex.decode('hex')
print(enc_ascii)
Traceback (most recent call last):
File ".\xxxx.py", line 7, in <module>
print(enc_ascii)
IOError: [Errno 2] No such file or directory
Well,in fact I want to know why "print" a special set of hex will cause file operation, other hex string will not error
Try using codecs.decode:
import codecs
enc_hex = '''f982f01c'''
enc_ascii = codecs.decode(enc_hex, 'hex')
print(enc_ascii)
Output:
b'\xf9\x82\xf0\x1c'
it seems like directory problems . in windows you have to use forward slash (/) while accessing the directory.similar was happened in my case then i use forward slash in windows then it works.
I want to search a Perforce depot for files.
I do this from a python script and use the p4python library command:
list = p4.run("files", "//mypath/myfolder/*")
This works fine as long as myfolder contains some files. I get a python list as a return value. But when there is no file in myfolder the program stops running and no error message is displayed. My goal is to get an empty python list, so that I can see that this folder doesn't contain any files.
Does anybody has some ideas? I could not find information in the p4 files documentation and on StackOverflow.
I'm going to guess you've got an exception handler around that command execution that's eating the exception and exiting. I wrote a very simple test script and got this:
C:\Perforce\test>C:\users\samwise\AppData\local\programs\python\Python36-32\python files.py
Traceback (most recent call last):
File "files.py", line 6, in <module>
print(p4.run("files", "//depot/no such path/*"))
File "C:\users\samwise\AppData\local\programs\python\Python36-32\lib\site-packages\P4.py", line 611, in run
raise e
File "C:\users\samwise\AppData\local\programs\python\Python36-32\lib\site-packages\P4.py", line 605, in run
result = P4API.P4Adapter.run(self, *flatArgs)
P4.P4Exception: [P4#run] Errors during command execution( "p4 files //depot/no such path/*" )
[Error]: "//depot/no such path/* - must refer to client 'Samwise-dvcs-1509687817'."
Try something like this ?
import os
if len(os.listdir('//mypath/myfolder/') ) == 0: # Do not execute p4.run if directory is empty
list = []
else:
list = p4.run("files", "//mypath/myfolder/*")
I've got a loop processing sockets, and I've set a pdb.set_trace() breakpoint to stop and inspect the results of the call to select.select() every time through the loop. However, there are also bugs elsewhere in my code, and it seems that the standard traceback is being overwritten by pdb.set_trace. As a result, when the program quits, the traceback points to the line immediately following the set_trace(), not the line that contained the error.
Is there a way to access the actual traceback, or does pdb.set_trace() clobber it?
Here's the relevant code snippet:
while True:
read_socks, write_socks, _ = select.select(all_sockets, all_sockets, '')
pdb.set_trace()
if listen_socket.fileno() in read_socks:
new_socket, address = listen_socket.accept()
id_num = new_socket.fileno()
all_sockets[id_num] = new_socket
for id_num in write_socks:
# do something that triggers an Assertion error
and then I get the traceback as follows:
Traceback (most recent call last):
File "socktactoe_server.py", line 62, in <module>
if listen_sock.fileno() in read_socks:
AssertionError
Here is a short reproducible test case; run it, hit c every time there is a breakpoint, after the second continue the assert raises an exception and it's reported for the wrong line:
import pdb
x = 0
while True:
pdb.set_trace()
y = "line of code not triggering an error"
x += 1
assert x != 3
Output:
Traceback (most recent call last):
File "minimal_pdb_traceback.py", line 7, in <module>
y = "line of code not triggering an error"
AssertionError
It looks like you found a bug in the Python pdb module! I can reproduce your simple case in Python versions 2.7, 3.2 and 3.3, while the problem is not present in Python 2.4, 2.5, 2.6 or 3.1.
At first glance, I don't see a preexisting bug in the python bug tracker. Please report your problem there, with your minimal test case, as well as what python versions it can be reproduced on.