protocol buffer error while creating annotations to my object detection project - python

How to solve this problem
I have never faced this kind of error before and cant find a way out
Anyone please help me out
Traceback (most recent call last):
File "D:\DK\Dev\Number-plate-detection\Tensorflow\scripts\generate_tfrecord.py", line 27, in <module>
import tensorflow.compat.v1 as tf
File "D:\DK\Dev\Number-plate-detection\npd\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "D:\DK\Dev\Number-plate-detection\npd\lib\site-packages\tensorflow\python\__init__.py", line 40, in <module>
from tensorflow.python.eager import context
File "D:\DK\Dev\Number-plate-detection\npd\lib\site-packages\tensorflow\python\eager\context.py", line 32, in <module>
from tensorflow.core.framework import function_pb2
File "D:\DK\Dev\Number-plate-detection\npd\lib\site-packages\tensorflow\core\framework\function_pb2.py", line 16, in <module>
from tensorflow.core.framework import attr_value_pb2 as tensorflow_dot_core_dot_framework_dot_attr__value__pb2
File "D:\DK\Dev\Number-plate-detection\npd\lib\site-packages\tensorflow\core\framework\attr_value_pb2.py", line 16, in <module>
from tensorflow.core.framework import tensor_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__pb2
File "D:\DK\Dev\Number-plate-detection\npd\lib\site-packages\tensorflow\core\framework\tensor_pb2.py", line 16, in <module>
from tensorflow.core.framework import resource_handle_pb2 as tensorflow_dot_core_dot_framework_dot_resource__handle__pb2
File "D:\DK\Dev\Number-plate-detection\npd\lib\site-packages\tensorflow\core\framework\resource_handle_pb2.py", line 16, in <module>
from tensorflow.core.framework import tensor_shape_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__shape__pb2
File "D:\DK\Dev\Number-plate-detection\npd\lib\site-packages\tensorflow\core\framework\tensor_shape_pb2.py", line 36, in <module>
_descriptor.FieldDescriptor(
File "D:\DK\Dev\Number-plate-detection\npd\lib\site-packages\google\protobuf\descriptor.py", line 560, in __new__
_message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
1. Downgrade the protobuf package to 3.20.x or lower.
2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).```

Related

Thonny py5-mode Error when running a code

I just tried to use py5 in thonny, but everytime i have the py5 mode on and try to run a code i get a bunch of error messeges, i dont really know what they mean so maybe somebody can help me out ?
thanks in advance
This is the error im always getting
Traceback (most recent call last):
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5_tools\tools\run_sketch.py", line 52, in <module>
main()
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5_tools\tools\run_sketch.py", line 44, in main
imported.run_code(
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5_tools\imported.py", line 135, in run_code
_run_code(
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5_tools\imported.py", line 259, in _run_code
_run_sketch(sketch_path, classpath, exit_if_error)
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5_tools\imported.py", line 196, in _run_sketch
import py5
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5\__init__.py", line 84, in <module>
from py5_tools.magics import load_ipython_extension # noqa
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5_tools\magics\__init__.py", line 22, in <module>
from .drawing import DrawingMagics, DXFDrawingMagic
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5_tools\magics\drawing.py", line 27, in <module>
from IPython.display import display, SVG, Image
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\IPython\__init__.py", line 51, in <module>
from .core.application import Application
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\IPython\core\application.py", line 26, in <module>
from IPython.core import release, crashhandler
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\IPython\core\crashhandler.py", line 27, in <module>
from IPython.core import ultratb
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\IPython\core\ultratb.py", line 101, in <module>
import stack_data
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\stack_data\__init__.py", line 1, in <module>
from .core import Source, FrameInfo, markers_from_ranges, Options, LINE_GAP, Line, Variable, RangeInLine, \
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\stack_data\core.py", line 19, in <module>
from stack_data.utils import (
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\stack_data\utils.py", line 11, in <module>
from asttokens import ASTText
ImportError: cannot import name 'ASTText' from 'asttokens' (C:\Users\schwe\AppData\Local\Programs\Thonny\lib\site-packages\asttokens\__init__.py)
I received a response from the py5 developer via Github. They also provided an explanation but it goes over my head, something about "The Python library asttokens is used for parsing syntax trees and syntax highlighting. It is not used by py5 but it might be used by Jupyter Notebook and/or JupyterLab.". They also provided a solution here:
enter link description here

AttributeError: module 'tensorflow.python.ops.linalg.linear_operator_util' has no attribute 'matmul_with_broadcast'

I am trying to create my own PyEnvironment for TF-Agents.
However, this error keeps showing up:
AttributeError: module 'tensorflow.python.ops.linalg.linear_operator_util' has no attribute 'matmul_with_broadcast'
I have found out that this seems to be an issue with tensorflow-probability, but I have installed the version tensorflow-probability=0.7.0 recommended at
https://github.com/tensorflow/agents/issues/91
I have tried reinstalling and updating
tensorflow-gpu=2.0.0-beta1
tf-agents-nightly
tensorflow-probability=0.7.0
Here is a minimal code example:
from tf_agents.environments import py_environment
class myEnv(py_environment.PyEnvironment):
def __init__(self):
pass
def _reset(self):
pass
def _step(self, action):
pass
This is the full error message when running this minimum example:
Traceback (most recent call last): File ".\env_mwe.py", line 1, in <module>
from tf_agents.environments import py_environment File "C:\Python37\lib\site-packages\tf_agents\environments\__init__.py", line 18, in <module>
from tf_agents.environments import batched_py_environment File "C:\Python37\lib\site-packages\tf_agents\environments\batched_py_environment.py", line 33, in <module>
from tf_agents.environments import py_environment File "C:\Python37\lib\site-packages\tf_agents\environments\py_environment.py", line 29, in <module>
from tf_agents.trajectories import time_step as ts File "C:\Python37\lib\site-packages\tf_agents\trajectories\__init__.py", line 19, in <module>
from tf_agents.trajectories import time_step File "C:\Python37\lib\site-packages\tf_agents\trajectories\time_step.py", line 28, in <module>
from tf_agents.specs import array_spec File "C:\Python37\lib\site-packages\tf_agents\specs\__init__.py", line 20, in <module>
from tf_agents.specs.distribution_spec import DistributionSpec File "C:\Python37\lib\site-packages\tf_agents\specs\distribution_spec.py", line 22, in <module>
import tensorflow_probability as tfp File "E:\Users\tmp\AppData\Roaming\Python\Python37\site-packages\tensorflow_probability\__init__.py", line 78, in <module>
from tensorflow_probability.python import * # pylint: disable=wildcard-import File "E:\Users\tmp\AppData\Roaming\Python\Python37\site-packages\tensorflow_probability\python\__init__.py", line 22, in <module>
from tensorflow_probability.python import distributions File "E:\Users\tmp\AppData\Roaming\Python\Python37\site-packages\tensorflow_probability\python\distributions\__init__.py", line 64, in <module>
from tensorflow_probability.python.distributions.linear_gaussian_ssm import LinearGaussianStateSpaceModel File "E:\Users\tmp\AppData\Roaming\Python\Python37\site-packages\tensorflow_probability\python\distributions\linear_gaussian_ssm.py", line 41, in <module>
_matmul = linear_operator_util.matmul_with_broadcast AttributeError: module 'tensorflow.python.ops.linalg.linear_operator_util' has no attribute 'matmul_with_broadcast'
Found it!
In order to use tensorflow-gpu with tensorflow-probability, one needs to install tfp-nightly
So pip3 install --upgrade tfp-nightly did the trick
To use 2.0.0beta1 requires tfp-nightly.

python3.5 import tensorflow.contrib error: Function has keyword-only arguments or annotations, use getfullargspec() API which can support them

I am using python 3.5 and installed tensorflow-gpu 1.12.0 on Linux. When I run this in python3.5:
import tensorflow as tf
It works fine with no errors.
However, when I run:
import tensorflow.contrib
There is an error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/myname/anaconda3/lib/python3.5/site-packages/tensorflow/contrib/__init__.py", line 49, in <module>
from tensorflow.contrib import distributions
File "/home/myname/anaconda3/lib/python3.5/site-packages/tensorflow/contrib/distributions/__init__.py", line 38, in <module>
from tensorflow.contrib.distributions.python.ops.estimator import *
File "/home/myname/anaconda3/lib/python3.5/site-packages/tensorflow/contrib/distributions/python/ops/estimator.py", line 21, in <module>
from tensorflow.contrib.learn.python.learn.estimators.head import _compute_weighted_loss
File "/home/myname/anaconda3/lib/python3.5/site-packages/tensorflow/contrib/learn/__init__.py", line 96, in <module>
from tensorflow.contrib.learn.python.learn import *
File "/home/myname/anaconda3/lib/python3.5/site-packages/tensorflow/contrib/learn/python/__init__.py", line 28, in <module>
from tensorflow.contrib.learn.python.learn import *
File "/home/myname/anaconda3/lib/python3.5/site-packages/tensorflow/contrib/learn/python/learn/__init__.py", line 30, in <module>
from tensorflow.contrib.learn.python.learn import estimators
File "/home/myname/anaconda3/lib/python3.5/site-packages/tensorflow/contrib/learn/python/learn/estimators/__init__.py", line 302, in <module>
from tensorflow.contrib.learn.python.learn.estimators.dnn import DNNClassifier
File "/home/myname/anaconda3/lib/python3.5/site-packages/tensorflow/contrib/learn/python/learn/estimators/dnn.py", line 35, in <module>
from tensorflow.contrib.learn.python.learn.estimators import dnn_linear_combined
File "/home/myname/anaconda3/lib/python3.5/site-packages/tensorflow/contrib/learn/python/learn/estimators/dnn_linear_combined.py", line 36, in <module>
from tensorflow.contrib.learn.python.learn.estimators import estimator
File "/home/myname/anaconda3/lib/python3.5/site-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 52, in <module>
from tensorflow.contrib.learn.python.learn.learn_io import data_feeder
File "/home/myname/anaconda3/lib/python3.5/site-packages/tensorflow/contrib/learn/python/learn/learn_io/__init__.py", line 26, in <module>
from tensorflow.contrib.learn.python.learn.learn_io.dask_io import extract_dask_data
File "/home/myname/anaconda3/lib/python3.5/site-packages/tensorflow/contrib/learn/python/learn/learn_io/dask_io.py", line 33, in <module>
import dask.dataframe as dd
File "/home/myname/anaconda3/lib/python3.5/site-packages/dask/dataframe/__init__.py", line 1, in <module>
from .core import (DataFrame, Series, Index, _Frame, map_partitions,
File "/home/myname/anaconda3/lib/python3.5/site-packages/dask/dataframe/core.py", line 23, in <module>
from .. import array as da
File "/home/myname/anaconda3/lib/python3.5/site-packages/dask/array/__init__.py", line 4, in <module>
from .core import (Array, stack, concatenate, take, tensordot, transpose,
File "/home/myname/anaconda3/lib/python3.5/site-packages/dask/array/core.py", line 13, in <module>
from toolz.curried import (pipe, partition, concat, unique, pluck, join, first,
File "/home/myname/anaconda3/lib/python3.5/site-packages/toolz/curried/__init__.py", line 53, in <module>
_curry_namespace(vars(toolz)),
File "/home/myname/anaconda3/lib/python3.5/site-packages/toolz/curried/__init__.py", line 48, in _curry_namespace
for name, f in ns.items() if '__' not in name
File "/home/myname/anaconda3/lib/python3.5/site-packages/toolz/curried/__init__.py", line 48, in <genexpr>
for name, f in ns.items() if '__' not in name
File "/home/myname/anaconda3/lib/python3.5/site-packages/toolz/curried/__init__.py", line 42, in _should_curry
return (callable(f) and _nargs(f) > 1 or f in do_curry)
File "/home/myname/anaconda3/lib/python3.5/site-packages/toolz/curried/__init__.py", line 35, in _nargs
return len(inspect.getargspec(f).args)
File "/home/myname/anaconda3/lib/python3.5/inspect.py", line 1050, in getargspec
raise ValueError("Function has keyword-only arguments or annotations"
ValueError: Function has keyword-only arguments or annotations, use getfullargspec() API which can support them
I searched for getfullargspec() API but got even more confused. As far as I know, the getfullargspec() API from inspect can only do with something like
getfullargsspec(function_name)
How can I do with it? I could appreciate it a lot if you could explain the cause and also possibly a simple solution.
Plus, I am running the code on a remote server without root permission. Command lines such as
sudo xxxxx
do not work for me.
Thank you for your help!
I also face this problem. I found this way to solve this problem.
conda install toolz
Good Luck

Theano tensor import error

I have been trying to import theano.tensor in my code.
I have used theano.tensor before. All of my previous code importing theano.tensor works perfectly in my machine. Now I am trying to write another script importing the tensor from theano and I am getting the following exception.
Traceback (most recent call last):
File "code.py", line 2, in <module>
import theano.tensor as T
File "/anaconda3/lib/python3.5/site-packages/theano/__init__.py", line 52, in <module>
from theano.gof import (
File "/anaconda3/lib/python3.5/site-packages/theano/gof/__init__.py", line 56, in <module>
from theano.gof.opt import (
File "/anaconda3/lib/python3.5/site-packages/theano/gof/opt.py", line 11, in <module>
import pdb
File "/anaconda3/lib/python3.5/pdb.py", line 75, in <module>
import code
File "/localtmp/saikat/CovInfo/Closure/code.py", line 2, in <module>
import theano.tensor as T
File "/anaconda3/lib/python3.5/site-packages/theano/tensor/__init__.py", line 6, in <module>
from theano.tensor.basic import *
File "/anaconda3/lib/python3.5/site-packages/theano/tensor/basic.py", line 17, in <module>
from theano.tensor import elemwise
File "/anaconda3/lib/python3.5/site-packages/theano/tensor/elemwise.py", line 13, in <module>
from theano import scalar
File "/anaconda3/lib/python3.5/site-packages/theano/scalar/__init__.py", line 2, in <module>
from .basic import *
File "/anaconda3/lib/python3.5/site-packages/theano/scalar/basic.py", line 25, in <module>
from theano import gof, printing
File "/anaconda3/lib/python3.5/site-packages/theano/printing.py", line 22, in <module>
from theano.compile import Function, debugmode, SharedVariable
File "/anaconda3/lib/python3.5/site-packages/theano/compile/__init__.py", line 9, in <module>
from theano.compile.function_module import *
File "/anaconda3/lib/python3.5/site-packages/theano/compile/function_module.py", line 22, in <module>
import theano.compile.mode
File "/anaconda3/lib/python3.5/site-packages/theano/compile/mode.py", line 77, in <module>
OPT_NONE = gof.Query(include=[], exclude=exclude)
AttributeError: module 'theano.gof' has no attribute 'Query'
I cannot find any plausible reason for this exception.
I guess i got your problem. See in the error log:
File "/anaconda3/lib/python3.5/pdb.py", line 75, in <module>
import code
I believe there is another script called code.py in Theano which gets called from pdb.py when python interpreter executes your script which is also named as code.py. I am guessing python interpreter is mixing up these two scripts and executing the wrong one! You can change the filename and check whether the error disappear or not.

Unable to load the package 'enthought.mayavi.mlab'

I'm trying to load the package enthought.mayavi.mlab in python's spider enviorment:
import enthought.mayavi.mlab as mlb
And I get the following error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 487, in runfile
execfile(filename, namespace)
File "C:\Users\Eytan\Desktop\Mah\PyBrainTraining.py", line 2, in <module>
import enthought.mayavi.mlab as mlb
File "C:\Python27\lib\site-packages\enthought\mayavi\mlab.py", line 3, in <module>
from mayavi.mlab import *
File "C:\Python27\lib\site-packages\mayavi\mlab.py", line 27, in <module>
from mayavi.tools.camera import view, roll, yaw, pitch, move
File "C:\Python27\lib\site-packages\mayavi\tools\camera.py", line 25, in <module>
from engine_manager import get_engine
File "C:\Python27\lib\site-packages\mayavi\tools\engine_manager.py", line 12, in <module>
from mayavi.preferences.api import preference_manager
File "C:\Python27\lib\site-packages\mayavi\preferences\api.py", line 4, in <module>
from preference_manager import preference_manager
File "C:\Python27\lib\site-packages\mayavi\preferences\preference_manager.py", line 29, in <module>
from traitsui.api import View, Group, Item
File "C:\Python27\lib\site-packages\traitsui\api.py", line 35, in <module>
from .editors.api import (ArrayEditor, BooleanEditor, ButtonEditor,
File "C:\Python27\lib\site-packages\traitsui\editors\__init__.py", line 22, in <module>
from .api import (toolkit, ArrayEditor, BooleanEditor, ButtonEditor,
File "C:\Python27\lib\site-packages\traitsui\editors\api.py", line 10, in <module>
from .code_editor import CodeEditor
File "C:\Python27\lib\site-packages\traitsui\editors\code_editor.py", line 36, in <module>
class ToolkitEditorFactory ( EditorFactory ):
File "C:\Python27\lib\site-packages\traitsui\editors\code_editor.py", line 48, in ToolkitEditorFactory
mark_color = Color( 0xECE9D8 )
File "C:\Python27\lib\site-packages\traits\traits.py", line 487, in __call__
return self.maker_function( *args, **metadata )
File "C:\Python27\lib\site-packages\traits\traits.py", line 1183, in Color
return ColorTrait( *args, **metadata )
File "C:\Python27\lib\site-packages\traitsui\toolkit_traits.py", line 7, in ColorTrait
return toolkit().color_trait( *args, **traits )
File "C:\Python27\lib\site-packages\traitsui\toolkit.py", line 109, in toolkit
_toolkit = _import_toolkit(ETSConfig.toolkit)
File "C:\Python27\lib\site-packages\traitsui\toolkit.py", line 51, in _import_toolkit
return __import__( name, globals=globals(), level=1 ).toolkit
File "C:\Python27\lib\site-packages\traitsui\qt4\__init__.py", line 18, in <module>
import pyface.qt
File "C:\Python27\lib\site-packages\pyface\qt\__init__.py", line 35, in <module>
prepare_pyqt4()
File "C:\Python27\lib\site-packages\pyface\qt\__init__.py", line 17, in prepare_pyqt4
sip.setapi('QString', 2)
ValueError: API 'QString' has already been set to version 1
anyone knows how to fix it?
Edit: If it will help, I see think that the problem is explained in the last column:
ValueError: API 'QString' has already been set to version 1
Edit: I tried changing API selection for QString and QVariant objects to Api #1,#2. didn't help.
Tried either to set the "Ignore API change errors" to true, didn't help.
Tried EST_TOOLKIT from 'qt4' to 'wx'.
It might be because spider itself uses the QT library and has already initialized it.
According to this http://pythonhosted.org/spyder/installation.html you could use PySide instead of PyQt4 (but i don't know if that's a configuation option or a fallback).

Categories

Resources