Expected binary or unicode string, got 0.0 - unicode

I'm training my first model with TensorFlow, but I keep having this error:
Expected binary or unicode string, got 0.0
I followed TensorFlow linear model tutorial (https://www.tensorflow.org/tutorials/wide) and applied it on my own dataset.
This is what I get:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/nick/anaconda3/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 289, in new_func
return func(*args, **kwargs)
File "/home/nick/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 455, in fit
loss = self._train_model(input_fn=input_fn, hooks=hooks)
File "/home/nick/anaconda3/lib/python3.6/site-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 953, in _train_model
features, labels = input_fn()
File "<stdin>", line 2, in train_input_fn
File "<stdin>", line 5, in input_fn
File "<stdin>", line 5, in <dictcomp>
File "/home/nick/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/constant_op.py", line 102, in constant
tensor_util.make_tensor_proto(value, dtype=dtype, shape=shape, verify_shape=verify_shape))
File "/home/nick/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/tensor_util.py", line 473, in make_tensor_proto
append_fn(tensor_proto, proto_values)
File "/home/nick/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/tensor_util.py", line 109, in SlowAppendObjectArrayToTensorProto
tensor_proto.string_val.extend([compat.as_bytes(x) for x in proto_values])
File "/home/nick/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/tensor_util.py", line 109, in <listcomp>
tensor_proto.string_val.extend([compat.as_bytes(x) for x in proto_values])
File "/home/nick/anaconda3/lib/python3.6/site-packages/tensorflow/python/util/compat.py", line 65, in as_bytes
(bytes_or_text,))
TypeError: Expected binary or unicode string, got 0.0
Any suggestion?
Thanks

Related

pyexcel suddenly no longer opens .xlsx (or .xls)

I have all the necessary dependencies installed:
pyexcel==0.7.0
pyexcel-ezodf==0.3.4
pyexcel-io==0.6.6
pyexcel-ods3==0.6.1
pyexcel-xls==0.7.0
(and some others, which I've omitted). Last week, my code was working. Now I am unable to open the very same .xls
>>> p = Path("data/jr1305221.xls")
>>> p.exists()
True
>>> pyexcel.get_book(file_name=p)
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "C:\Users\User McUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pyexcel\core.py", line 47, in get_book
book_stream = sources.get_book_stream(**keywords)
File "C:\Users\User McUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pyexcel\internal\core.py", line 36, in get_book_stream
a_source = SOURCE.get_book_source(**keywords)
File "C:\Users\User McUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pyexcel\internal\source_plugin.py", line 85, in get_book_source
return self.get_a_plugin(
File "C:\Users\User McUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pyexcel\internal\source_plugin.py", line 69, in get_a_plugin
source_cls = self.load_me_now(
File "C:\Users\User McUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pyexcel\internal\source_plugin.py", line 41, in load_me_now
if source.is_my_business(action, **keywords):
File "C:\Users\User McUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pyexcel\plugins\__init__.py", line 56, in is_my_business
raise IOError("Unsupported file type")
OSError: Unsupported file type
>>>
or .xlsx
>>> p = Path('data/dummy.xlsx')
>>> p.exists()
True
>>> pyexcel.get_book(file_name=p)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\User McUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pyexcel\core.py", line 47, in get_book
book_stream = sources.get_book_stream(**keywords)
File "C:\Users\User McUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pyexcel\internal\core.py", line 36, in get_book_stream
a_source = SOURCE.get_book_source(**keywords)
File "C:\Users\User McUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pyexcel\internal\source_plugin.py", line 85, in get_book_source
return self.get_a_plugin(
File "C:\Users\User McUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pyexcel\internal\source_plugin.py", line 69, in get_a_plugin
source_cls = self.load_me_now(
File "C:\Users\User McUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pyexcel\internal\source_plugin.py", line 41, in load_me_now
if source.is_my_business(action, **keywords):
File "C:\Users\User McUser\AppData\Local\Programs\Python\Python310\lib\site-packages\pyexcel\plugins\__init__.py", line 56, in is_my_business
raise IOError("Unsupported file type")
OSError: Unsupported file type
>>>
Even in my docker container, it's stopped working.
As an alternative, I have also tried
with open('data/dummy.xlsx', 'r') as f:
pyexcel.get_book(file_name=f)
and get the same error.
I have read the docs again. I have rolled back my code to last week. What have I done to deserve this? Why has god forsaken me?
file_name needs to be a string, where I was passing in a pathlib.PosixPath
i.e., this returns the error:
p = Path('my_file')
pyexcel.get_book(file_name=p)
this works:
pyexcel.get_book(file_name='my_file')
You can use pyexcel.get_book(file_name=my_file.as_posix()) to get the string representation from the PosixPath.

Write Function Result to XML on Powershell

I'm using a Template tool https://github.com/noahmorrison/chevron (Mustache Impl)
My issue is that when I run it on powershell and I try to save the result to a file doing:
chevron C:\templates\db.mustache -d C:\temp\db\dev.json | ConvertTo-Xml > .\Process.xml
Note the function prompts an XML
I get the error:
Traceback (most recent call last):
File "c:\users\kevin.haunstetter\appdata\local\programs\python\python38-32\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\users\kevin.haunstetter\appdata\local\programs\python\python38-32\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\kevin.haunstetter\AppData\Local\Programs\Python\Python38-32\Scripts\chevron.exe\__main__.py", line 7, in <module>
File "c:\users\kevin.haunstetter\appdata\local\programs\python\python38-32\lib\site-packages\chevron\main.py", line 84, in cli_main
sys.stdout.write(main(**args))
File "c:\users\kevin.haunstetter\appdata\local\programs\python\python38-32\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\ufeff' in position 0: character maps to <undefined>
Any idea?

Python Keyerror 'sapi5', cant understand the error

One question of this type is previously asked but is not very helpful. I am using version Python3.8 in Windows 10 OS. I am getting an error, KeyError: 'sapi5'. dont know why this error is occurring. Please have a look at the below code given . My code is-
import pyttsx3
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
engine.setProperty('voices', voices[0].id)
The Error is quite big. can anyone help me?
Traceback (most recent call last):
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyttsx3\__init__.py", line 20, in init
eng = _activeEngines[driverName]
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\weakref.py", line 131, in __getitem__
o = self.data[key]()
KeyError: 'sapi5'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyttsx3\drivers\sapi5.py", line 3, in <module>
from comtypes.gen import SpeechLib # comtypes
ImportError: cannot import name 'SpeechLib' from 'comtypes.gen' (C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\gen\__init__.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\ctypes\__init__.py", line 123, in WINFUNCTYPE
return _win_functype_cache[(restype, argtypes, flags)]
KeyError: (<class 'ctypes.HRESULT'>, (<class 'ctypes.c_long'>, <class 'comtypes.automation.tagVARIANT'>, <class 'comtypes.automation.tagVARIANT'>, <class 'ctypes.c_long'>, <class 'ctypes.c_long'>), 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "g:/saurav/Assistant/VA/MyAssistant.py", line 9, in <module>
engine = pyttsx3.init('sapi5')
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyttsx3\__init__.py", line 22, in init
eng = Engine(driverName, debug)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyttsx3\engine.py", line 30, in __init__
self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyttsx3\driver.py", line 50, in __init__
self._module = importlib.import_module(name)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pyttsx3\drivers\sapi5.py", line 6, in <module>
engine = comtypes.client.CreateObject("SAPI.SpVoice")
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\client\__init__.py", line 250, in CreateObject
return _manage(obj, clsid, interface=interface)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\client\__init__.py", line 188, in _manage
obj = GetBestInterface(obj)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\client\__init__.py", line 110, in GetBestInterface
mod = GetModule(tlib)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\client\_generate.py", line 110, in GetModule
mod = _CreateWrapper(tlib, pathname)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\client\_generate.py", line 184, in _CreateWrapper
mod = _my_import(fullname)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\client\_generate.py", line 24, in _my_import
return __import__(fullname, globals(), locals(), ['DUMMY'])
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\gen\_C866CA3A_32F7_11D2_9602_00C04F8EE628_0_5_4.py", line 140, in <module>
ISpeechRecoGrammar._methods_ = [
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\__init__.py", line 329, in __setattr__
self._make_methods(value)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\site-packages\comtypes\__init__.py", line 698, in _make_methods
prototype = WINFUNCTYPE(restype, *argtypes)
File "C:\Users\hp\AppData\Local\Programs\Python\Python38-32\lib\ctypes\__init__.py", line 125, in WINFUNCTYPE
class WinFunctionType(_CFuncPtr):
TypeError: item 2 in _argtypes_ passes a union by value, which is unsupported.
first uninstall pyttsx3 using following command
pip uninstall pyttsx3
Then install pyttsx3 version 2.6 using following command
pip install pyttsx3==2.6

Is there any example of how to use the digital input or analog input of GPIO on google aiy voice board?

I can not read the input from the motion sensor (HC-SR501) which connects to PIN_A of the expansion pins on the voice bonnet of my aiy voice kit.
Below are the code and the error message, please shed some light.
Code:
from gpiozero import MotionSensor
from aiy.pins import (PIN_A, PIN_B, PIN_C, PIN_D)
pir = MotionSensor(PIN_A)
pir.wait_for_motion()
print("Motion detected!")
Error message:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/gpiozero/input_devices.py", line 51, in __init__
self.pin.pull = pull
File "/usr/lib/python3/dist-packages/gpiozero/pins/__init__.py", line 279, in <lambda>
lambda self, value: self._set_pull(value),
File "/opt/aiy/projects-python/src/aiy/pins.py", line 569, in _set_pull
'Only pull up is supported right now (%s)' % pull)
gpiozero.exc.PinFixedPull: Only pull up is supported right now (down)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "motion_sensor.py", line 4, in <module>
pir = MotionSensor(PIN_A)
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 95, in __call__
self = super(GPIOMeta, cls).__call__(*args, **kwargs)
File "/usr/lib/python3/dist-packages/gpiozero/input_devices.py", line 451, in __init__
pin_factory=pin_factory
File "/usr/lib/python3/dist-packages/gpiozero/input_devices.py", line 163, in __init__
pin, pull_up, pin_factory=pin_factory
File "/usr/lib/python3/dist-packages/gpiozero/mixins.py", line 164, in __init__
super(EventsMixin, self).__init__(*args, **kwargs)
File "/usr/lib/python3/dist-packages/gpiozero/input_devices.py", line 53, in __init__
self.close()
File "/usr/lib/python3/dist-packages/gpiozero/input_devices.py", line 185, in close
super(SmoothedInputDevice, self).close()
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 393, in close
self.pin_factory.release_pins(self, self._pin.number)
AttributeError: 'HatPin' object has no attribute 'number'
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 483, in _shutdown
_devices_shutdown()
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 476, in _devices_shutdown
dev.close()
File "/usr/lib/python3/dist-packages/gpiozero/input_devices.py", line 185, in close
super(SmoothedInputDevice, self).close()
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 393, in close
self.pin_factory.release_pins(self, self._pin.number)
AttributeError: 'HatPin' object has no attribute 'number'
Exception ignored in: <object repr() failed>
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 122, in __del__
self.close()
File "/usr/lib/python3/dist-packages/gpiozero/input_devices.py", line 185, in close
super(SmoothedInputDevice, self).close()
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 393, in close
self.pin_factory.release_pins(self, self._pin.number)
AttributeError: 'HatPin' object has no attribute 'number'
Did you solve it?
By looking at the API and your error message, try changing line 3 of your code
From:
pir = MotionSensor(PIN_A)
To:
pir = MotionSensor(PIN_A, pull_up=True)

WARNING: Readline services not available or not loaded.AttributeError: 'module' object has no attribute 'set_completer_delims'

REPL run ipython an error occurred.
WARNING: Readline services not available or not loaded.
Traceback (most recent call last):
File "C:\Program Files\Sublime Text 3\Data\Packages/SublimeREPL/config/Python/ipy_repl.py", line 52, in <module>
embedded_shell.initialize()
File "<string>", line 2, in initialize
File "D:\Python27\lib\site-packages\IPython\config\application.py", line 75, in catch_config_error
return method(app, *args, **kwargs)
File "D:\Python27\lib\site-packages\IPython\terminal\ipapp.py", line 332, in initialize
self.init_shell()
File "D:\Python27\lib\site-packages\IPython\terminal\console\app.py", line 114, in init_shell
client=self.kernel_client,
File "D:\Python27\lib\site-packages\IPython\config\configurable.py", line 337, in instance
inst = cls(*args, **kwargs)
File "D:\Python27\lib\site-packages\IPython\core\interactiveshell.py", line 524, in __init__
self.init_completer()
File "D:\Python27\lib\site-packages\IPython\terminal\console\interactiveshell.py", line 129, in init_completer
self.Completer = ZMQCompleter(self, self.client, config=self.config)
File "D:\Python27\lib\site-packages\IPython\terminal\console\completer.py", line 37, in __init__
self.readline.set_completer_delims('\r\n')
AttributeError: 'module' object has no attribute 'set_completer_delims'
I experienced this problem whilst running ipython console in the WinPython distribution. In my case the problem was fixed by installing pyreadline:
pip install pyreadline
Hope this works for you too.