I using the raw_input API in python 2.7
I do:
mass_storage_choice = raw_input("Have you enabled USB mass storage on the phone Yes or No?");
I get:
Traceback (most recent call last):
File "C:\tools\ide\juno\eclipse\plugins\org.python.pydev_2.7.3.2013031601\pysrc\pydevd_comm.py", line 765, in doIt
result = pydevd_vars.evaluateExpression(self.thread_id, self.frame_id, self.expression, self.doExec)
File "C:\tools\ide\juno\eclipse\plugins\org.python.pydev_2.7.3.2013031601\pysrc\pydevd_vars.py", line 376, in evaluateExpression
result = eval(compiled, updated_globals, frame.f_locals)
File "<string>", line 1, in <module>
NameError: name 'Y' is not defined
Any ideas why?
In-case you are using an if...then loop in the code make sure you actually put Y in single quotes.Like this 'Y'.Because I am getting a feeling you are processing the Y input which according to me, means yes.Correct me if I am wrong.
Once you get the input from user pass the input to a variable to be defined that should work.
Related
I try to execute the file 'pbapclient.py'. I downloaded the files from https://github.com/bmwcarit/pypbap , but the console prompt show me some errors. I want to print/save all my contact from my android phone(I've got htc one m9).I run antergos. I try for at least 4 month... thanks for the help.
This is the prompt
[mattia#LinuxMattia pypbap-master]$ python3 pbapclient.py
Traceback (most recent call last): File "pbapclient.py", line 22, in
<module> from PyOBEX import client File "/usr/lib/python3.7/site-
packages/PyOBEX/client.py", line 489, in <module>
class SyncClient(Client): File "/usr/lib/python3.7/site-
packages/PyOBEX/client.py", line 491, in SyncClient
def connect(self, header_list = (headers.Target("IRMC-SYNC"),)):
File "/usr/lib/python3.7/site-packages/PyOBEX/headers.py", line 33, in
__init__
self.data = self.encode(data)
File "/usr/lib/python3.7/site-packages/PyOBEX/headers.py", line 48, in
encode return struct.pack(">BH", self.code, len(data) + 3) + data
TypeError: can't concat str to bytes
Thanks for the help
The installation guide (https://github.com/bmwcarit/pypbap#installation) tells you that the program needs to be run with python2, however you were using python3.
So I'm trying to get scapy to work on my windows computer. After a lot of work I finally was able to load the library without any errors. However when I call the function sniff(count=1) I get an error. It seems that a variable called "device" is getting the value None. Here is the error :
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python34\lib\site-packages\scapy\arch\windows\__init__.py", line 445, in sniff
s = L2socket(type=ETH_P_ALL, *arg, **karg)
File "C:\Python34\lib\site-packages\scapy\arch\pcapdnet.py", line 266, in __init__
self.ins = open_pcap(iface, 1600, self.promisc, 100)
File "C:\Python34\lib\site-packages\scapy\arch\windows\__init__.py", line 223, in <lambda>
pcapdnet.open_pcap = lambda iface,*args,**kargs: _orig_open_pcap(pcap_name(iface),*args,**kargs)
File "C:\Python34\lib\site-packages\scapy\arch\pcapdnet.py", line 251, in <lambda>
open_pcap = lambda *args,**kargs: _PcapWrapper_pypcap(*args,**kargs)
File "C:\Python34\lib\site-packages\scapy\arch\pcapdnet.py", line 215, in __init__
self.iface = create_string_buffer(device.encode('ascii'))
AttributeError: 'NoneType' object has no attribute 'encode'
Thanks In Advance For Any Help :)
After downloading the new development version and tinkering around with the timeouts of some of the powershell commands I fixed it! Guess it was just a bug with the old version. Scapy doesn't have the best Windows support.
I'm trying to automate tasks for teamcenter using pywinauto python module.But I was not able to work properly with TreeViews. When ever I'm trying to use GetItem(),SubElements(),Item() and many other function under _treeview_element giving error.Please look into below errors.
I'm using python 2.7 and i also have pywin32 module installed
for i in range(tr.ItemCount()):
print tr.GetItem(i)
Traceback (most recent call last):
File "<pyshell#61>", line 2, in <module>
print tr.GetItem(i) File "C:\Users\patibj\Desktop\pywinauto-
master\pywinauto\controls\common_controls.py", line 1010, in GetItem
if isinstance(path[0], int):
TypeError: 'int' object has no attribute '__getitem__'
This is when i'm trying to use GetChild()
a[0] is <pywinauto.controls.common_controls._treeview_element object at 0x02EC11B0> a[0].GetChild((1))
Traceback (most recent call last):
File "<pyshell#49>", line 1, in <module>
a[0].GetChild((1))
File "C:\Users\patibj\Desktop\pywinauto- master\pywinauto\controls\common_controls.py", line 840, in GetChild
return self.Children()[index]
File "C:\Users\patibj\Desktop\pywinauto-master\pywinauto\controls\common_controls.py", line 739, in Children
if self.Item().cChildren not in (0, 1):
File "C:\Users\patibj\Desktop\pywinauto-master\pywinauto\controls\common_controls.py", line 539, in Item
return self._readitem()[0]
File "C:\Users\patibj\Desktop\pywinauto-master\pywinauto\controls\common_controls.py", line 904, in _readitem
raise ctypes.WinError() WindowsError: [Error 0] The operation completed successfully.
Please help me out .Thanks in advance.
TreeViewWrapper.GetItem() method gets path argument which should be the string starting with back-slash \\ symbol. Example:
app.Dialog.TreeView.GetItem('\\1st_level_item_name\\2ndlevelitem').Click()
For access by index use a list of integers:
app.Dialog.TreeView.GetItem([1, 0])
GetChild() works with explorer.exe TreeView:
>>> tree.GetItem([1]).GetChild(2).Text()
u'Computer'
Hi i have just started learning image processing using python.
When i tried to open an image that i downloaded from the net, I keep getting this error and I have no idea about how to resolve it. Can anyone please help me with this?
>>> dna=mahotas.imread('dna.jpeg')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\mahotas\io\freeimage.py", line 773, in imread
img = read(filename)
File "C:\Python27\lib\site-packages\mahotas\io\freeimage.py", line 444, in read
bitmap = _read_bitmap(filename, flags)
File "C:\Python27\lib\site-packages\mahotas\io\freeimage.py", line 490, in _read_bitmap
'mahotas.freeimage: cannot determine type of file %s' % filename)
ValueError: mahotas.freeimage: cannot determine type of file dna.jpeg
Hello this looks like a pretty old thread but I found it recently because I had the same problem.
I think that the error message is misleading because it implies that the type of file is incorrect.
I fixed the problem by including the full path to the image file. For example, it could look something like:
dna = mahotas.imread('C:\Documents\dna.jpeg')
Hello is use eclipse and pydev, I was wondering why my sample code won't work trying to use the while function.
print("Welcome to the annoying program")
response = ""
while response != "Because.":
response = input("why\n")
print("Oh,ok")
the output is the following:
Welcome to the annoying program
why
Because.
Traceback (most recent call last):
File "/Users/calebmatthias/Document/workspace/de.vogella.python.first/simpprogram.py", l ine 9, in <module>
response = input("why\n")
File "/Users/calebmatthias/Desktop/eclipse 2/plugins/org.python.pydev_2.2.3.2011100616/PySrc/pydev_sitecustomize/sitecustomize.py", line 210, in input
return eval(raw_input(prompt))
File "<string>", line 1
Because.
^
SyntaxError: unexpected EOF while parsing
The input function in 2.x evaluates the input as Python code! Use the raw_input function instead.
With input, your text "Because." is being evaluated, and it's a syntax error because the dot isn't followed by anything.