Python3 decode doesn't work on mac - decode

I wrote this code:
'\xe4\xf6\xfc'.decode('latin1')
but I got this:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'str' object has no attribute 'decode'
I am using python 3.4 and I am using python on mac.

Because the string type does not support the .decode() method in Python 3. Simply prefix your string with b, which turns it into the bytes type:
>>> b'\xe4\xf6\xfc'.decode('latin1')
'äöü'

Related

Python gprc AttributeError: 'NoneType' object has no attribute 'message_types_by_name'

I just want to complete a simple demo, but I got this error message.
Traceback (most recent call last):
File "E:/grpc/biliService.py", line 10, in <module>
import hello_bilibili_pb2 as pb2
File "E:\grpc\hello_bilibili_pb2.py", line 21, in <module>
_HELLODEWEIREQ = DESCRIPTOR.message_types_by_name['HelloDeweiReq']
AttributeError: 'NoneType' object has no attribute 'message_types_by_name'
grpcio==1.30.0
grpcio-tools==1.30.0
The latest grpcio version 1.44.0 generate incompatible pb2 files, so I've seen the same question, I downgrade grpcio 1.30.0, and it worked.

Pyueye IDS Camera

I am working with IDS camera and they have a python module called pyueye. I installed it using pip, but it seems like the dll are missing:
Traceback (most recent call last):
File "/home/bikram/.local/lib/python3.8/site-packages/pyueye/dll.py", line 166, in load_dll
dll = DLL(libinfo, libnames, os.getenv(envname))
File "/home/bikram/.local/lib/python3.8/site-packages/pyueye/dll.py", line 96, in __init__
raise RuntimeError("could not find any library for {} ({})".format(libinfo, dllmsg))
RuntimeError: could not find any library for ueye_api (DLL_PATH: unset)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/bikram/Documents/uEye/1.py", line 1, in <module>
from pyueye import ueye
File "/home/bikram/.local/lib/python3.8/site-packages/pyueye/__init__.py", line 56, in <module>
from . import ueye
File "/home/bikram/.local/lib/python3.8/site-packages/pyueye/ueye.py", line 58, in <module>
get_dll_file, _bind = load_dll("ueye_api", ["ueye_api_64", "ueye_api"], "PYUEYE_DLL_PATH")
File "/home/bikram/.local/lib/python3.8/site-packages/pyueye/dll.py", line 168, in load_dll
raise ImportError(exc)
ImportError: could not find any library for ueye_api (DLL_PATH: unset)
I noticed someone else had the same issue in windows.
Does anyone else have the same issue using pyeue?
I had same issue but then I downloaded IDS Software Suite from https://en.ids-imaging.com/
Installed it and everything worked. Give it a try.
It will also let you configure their camera from IDS Camera Manager before you use it from Python.

Why do I get an error message although I have installed thonny sqlite3 correctly

I want to use thonny sqlite3. I am installing sqlite3 module with Thonny Manage Packages.But after typing import sqlite3, when I want to run it in this state, it gives the following error message:
File "<stdin>", line 3, in <module>
File "/lib/sqlite3.py", line 11, in <module>
AttributeError: 'NoneType' object has no attribute 'func'
Thank for your help.

NameError : name 'ip' is not defined

after installing scapy in windows when I run the "scapy" command from command line to check if scapy is installed succesfully
it gives the following lines:
welcome to Scapy(2.1.1-dev)
>>>ip
Traceback (most recent call last):
File "<console>", line 1, in <module>
NameError: name 'ip' is not defined
how to fix this error?
Try.. doing this .. this would create a IP object and print it
>>>> print IP()
Or else populating IP options is explained in detail here: http://allievi.sssup.it/techblog/?p=631
>>> ip=IP(src="1.1.1.1", dst="8.8.8.8", options=IPOption('\x83\x03\x10'))

cx_freeze error with pyodbc

if you have a simple program name pyodbcTest.py
import pyodbc
print "pass"
and then use cx_freeze to compile it
cxfreeze --targe-dir=cxTest pyodbcTest.py
and then run that program it throws the following error.
C:\temp\pythonWork\cxTest>pyodbcTest.exe
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27, in <module>
exec code in m.__dict__
File "pyodbcTest.py", line 1, in <module>
RuntimeError: Unable to import decimal
Any ideas?
I had to add the option --include-module decimal to solve the problem. Not sure why it could not find that one on its own during the freeze process, but its working now

Resources