ModuleNotFoundError: No module named 'tflite_support.task' - raspberry-pi

tflite_support's task library is missing. I've install the tflite_support with pip install tflite-support. I've tried using help() function to get the pakage content with help(tflite_support) and got the output 'PACKAGE CONTENTS
_pywrap_codegen
_pywrap_flatbuffers codegen
flatbuffers (package)
metadata
metadata_schema_py_generated
schema_py_generated'. There is no task library inside like how the tflite website shows https://www.tensorflow.org/lite/inference_with_metadata/task_library/object_detector#run_inference_in_python. I get the same result doing it in my window pc. Am I doing anything wrong or the task library is just missing?

I'm using tflite-support 0.4.1 and it looks like the task module is not supported on Windows:
import flatbuffers
import platform
from tensorflow_lite_support.metadata import metadata_schema_py_generated
from tensorflow_lite_support.metadata import schema_py_generated
from tensorflow_lite_support.metadata.python import metadata
from tflite_support import metadata_writers
if platform.system() != 'Windows':
# Task Library is not supported on Windows yet.
from tflite_support import task
There's also a note about it in the task_library docs.

Related

QGIS plugin - getting ModuleNotFoundError when importing specifically python-ternary

I am building a QGIS plugin and I'd like to import a module named python-ternary. I have a specific issue importing this module (others get imported), and importing it in QGIS (works outside of QGIS).
I installed it using pip, tried to import it outside of QGIS, works fine.
Now writing this in my plugin main file:
from qgis.PyQt.QtCore import QSettings, QTranslator, QCoreApplication, Qt
from qgis.PyQt.QtGui import QIcon, QColor
from qgis.PyQt.QtWidgets import QAction, QApplication
from .resources import *
import psycopg2
import ternary
I get this when loading my plugin with the QGIS plugin manager:
QGIS error when loading the plugin
Now the python-ternary module is well installed in lib\site-packages:
ternary file in lib\site-packages
And lib\site-packages is on path as shown in the QGIS error.
I have no problem importing other modules in QGIS e.g. psycopg2 is imported without issue. I force reinstalled python-ternary with pip, to no avail.
Is there a compatibility issue with this particular module I'm not aware of ?

compiled Python3 module produces error "dynamic module does not define module export function"

I am trying to compile a Python package that I recently migrated from Python2 to Python3.
When running the source code in Python3 it works as expected, so do the source and compiled versions for Python2, but when I cythonize and compile the Python3 package the resulting binaries throw this error when importing a certain module:
dynamic module does not define module export function (PyInit_NKPD)
EDIT:
When I then close the Python interpreter, open it again and import the same model it works.
Interestingly when I put the code on my local drive it imports fine, but when I put it on my server and import it from there I get the above error. And to make matters worse, sometimes it imports fine from the server as well if I just wait a while and try again:
lockjaw:controller frank$ python3.7
Python 3.7.7 (v3.7.7:d7c567b08f, Mar 10 2020, 02:56:16)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import common
added to sys.path: /opt/ohufx/transfer/NUBRIDGE_COMPILE/osx/NKPD/src
trying to import model.NukepediaDB...
NukepediaDB imported
trying to import model.NKPD...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "src/controller/common.py", line 15, in init controller.common
import model.NKPD # this does not import
ImportError: dynamic module does not define module export function (PyInit_NKPD)
>>> import common
added to sys.path: /opt/ohufx/transfer/NUBRIDGE_COMPILE/osx/NKPD/src
trying to import model.NukepediaDB...
trying to import model.NKPD...
NKPD imported
model.NKPD always seems to import fine, but model.NKPD seems to be the stumbling block, even though this may be a red herring. It almost behaves like sometimes the server connection drops out after the first import, though in that case the other incarnations (Python 2/source code) would throw errors as well (not to mention a whole lot of other things would break in my office).
I have reduced the package to three modules with nothing but import and print statements which can be found here (including the resuling C++ and binary files).
The structure is very simple:
Where common is the module I import to test by cd-ing into the src/controller folder, opening Python3.7 and importing common. Common then imports model.NukepediaDB and model.NKPD, the latter causing the trouble.
I cythonized the python files with this line:
/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 py2cpp.py
Then compiled with this:
/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 setup.py build_ext --inplace
I would love to understand why the import sometimes fails when run from the server, as I have to distribute this package to others and need to ensure it runs reliably.
Thanks,
Frank

No module named 'gcp_sql_operator' in cloud composer

I am not able to import statement as-
from airflow.contrib.operators.gcp_sql_operator import CloudSqlQueryOperator
I want to import this in my DAG file which will be run in cloud composer airflow whose version is 1.10.0 and not 1.9.0.Here just to check, I tried to import gcs_to_gcs as-
from airflow.contrib.operators.gcs_to_gcs import GoogleCloudStorageToGoogleCloudStorageOperator
I am able to import this but not gcp_sql_operator.
The CloudSqlQueryOperator operator is released since Airflow 1.10.2, which is currently not supported in Composer versions. The support for 1.10.2 should be available soon in Composer, before that you may want to manually copy gcp_sql_operator.py and its dependencies to the Composer dags folder following the instruction here.

import statsmodels package returns ModuleNotFound despite correct path

I am trying to import statsmodels.stats.weightstats.DescrStatsW.tconfint_mean.
I run
from statsmodels.stats.weightstats.DescrStatsW import tconfint_mean
I get the error
ModuleNotFoundError: No module named
'statsmodels.stats.weightstats.DescrStatsW';
'statsmodels.stats.weightstats' is not a package
I have confirmed that I can import other packages from statsmodels with no problems.
I must be using the wrong path, but the docs don't specify any other path to use.
I just figured it out. I will leave this up for progeny.
from statsmodels.stats.weightstats import DescrStatsW
DescrStatsW.tconfint_mean(...)
Not sure why this behaves differently from other python libraries.

Import Leaflet.awesome-marker in angular/cli component

I want to use the Leaflet.awesome-marker plugin in my angular project.
I installed the package throught yarn and imported in my component using
import * as awesome from 'leaflet.awesome-marker';
But I receive the following error:
Cannot find module 'leaflet.awesome-marker'
Doing the same thing with the geojson module works fine, why not with this one?
Try importing leaflet.awesome-markers, not leaflet.awesome-marker