How to fix "calibration_pb2 from 'object_detection.protos' " error (Windows) - tensorflow

I've tried to run the below code but it always gives a set of errors. I tried searching the answers but none work for my code, there are two files named 'object_detection' one in the research folder and other in the object_detection-0.1-py3.7.egg folder which might be causing the error but i tried to change the path but the errors still persist
I'm trying to execue this command:
C:\tensorflow1\models\research\object_detection>python train.py --
logtostderr --train_dir=training/ --
pipeline_config_path=training/faster_rcnn_inception_v2_pets.config
but have the following errors coming up:
Traceback (most recent call last):
1. File "train.py", line 51, in <module>
from object_detection.builders import model_builder
2. File "C:\Users\Swayam\mypython\lib\site-packages\object_detection-
0.1-
py3.7.egg\object_detection\builders\model_builder.py", line 27, in
<module>
from object_detection.builders import post_processing_builder
3. File "C:\Users\Swayam\mypython\lib\site-packages\object_detection-
0.1-
py3.7.egg\object_detection\builders\post_processing_builder.py",
line 2
2, in <module>
from object_detection.protos import post_processing_pb2
4. File "C:\Users\Swayam\mypython\lib\site-packages\object_detection-
0.1-
py3.7.egg\object_detection\protos\post_processing_pb2.py", line 15,
in
<module>
from object_detection.protos import calibration_pb2 as
object__detection_dot_protos_dot_calibration__pb2
5. ImportError: cannot import name 'calibration_pb2' from
'object_detection.protos' (C:\Users\Swayam\mypython\lib\site-
packages\object_detection-0.1-
py3.7.egg\object_detection\protos\__init__.py)
I've tried using the
protoc object_detection/protos/*.proto --python_out=.
command but it brings up errors too.
Also, the environment is not made in conda, could that be the cause of the error? Though all the necessary installations are present in the existing virtual environment.

Try this Solution:
Check if the file
"calibration_pb2.py"
is located in the following path, in your case may be this one:
C:\Users\Swayam\mypython\lib\site-packages\object_detection-0.1-
py3.7.egg\object_detection\protos\
If not, just copy it from your working path:
C:\tensorflow1\models\research\object_detection\protos\
If it works, I sugggest you try to copy all the *pb2.py files into the path mentioned above.

you just compile this
protoc --python_out=. .\object_detection\protos\anchor_generator.proto .\object_detection\protos\argmax_matcher.proto .\object_detection\protos\bipartite_matcher.proto .\object_detection\protos\box_coder.proto .\object_detection\protos\box_predictor.proto .\object_detection\protos\eval.proto .\object_detection\protos\faster_rcnn.proto .\object_detection\protos\faster_rcnn_box_coder.proto .\object_detection\protos\grid_anchor_generator.proto .\object_detection\protos\hyperparams.proto .\object_detection\protos\image_resizer.proto .\object_detection\protos\input_reader.proto .\object_detection\protos\losses.proto .\object_detection\protos\matcher.proto .\object_detection\protos\mean_stddev_box_coder.proto .\object_detection\protos\model.proto .\object_detection\protos\optimizer.proto .\object_detection\protos\pipeline.proto .\object_detection\protos\post_processing.proto .\object_detection\protos\preprocessor.proto .\object_detection\protos\region_similarity_calculator.proto .\object_detection\protos\square_box_coder.proto .\object_detection\protos\ssd.proto .\object_detection\protos\ssd_anchor_generator.proto .\object_detection\protos\string_int_label_map.proto .\object_detection\protos\train.proto .\object_detection\protos\keypoint_box_coder.proto .\object_detection\protos\multiscale_anchor_generator.proto .\object_detection\protos\graph_rewriter.proto .\object_detection\protos\calibration.proto
it will resolve the issue

Related

Procedure entry point gzdirect could not be located in the dynamic link library

I tried to run the below command
conda create --name tf_gpu tensorflow-gpu
and it throws the error
Traceback (most recent call last):
File "C:\Users\alexk\Anaconda3\lib\site-packages\conda\exceptions.py", line 1062, in call
return func(*args, **kwargs)
File "C:\Users\alexk\Anaconda3\lib\site-packages\conda\cli\main.py", line 84, in _main
exit_code = do_call(args, p)
File "C:\Users\alexk\Anaconda3\lib\site-packages\conda\cli\conda_argparse.py", line 82, in do_call
exit_code = getattr(module, func_name)(args, parser)
File "C:\Users\alexk\Anaconda3\lib\site-packages\conda\cli\main_create.py", line 37, in execute
install(args, parser, 'create')
File "C:\Users\alexk\Anaconda3\lib\site-packages\conda\cli\install.py", line 116, in install
if context.use_only_tar_bz2:
File "C:\Users\alexk\Anaconda3\lib\site-packages\conda\base\context.py", line 664, in use_only_tar_bz2
import conda_package_handling.api
File "C:\Users\alexk\Anaconda3\lib\site-packages\conda_package_handling\api.py", line 12, in
from .tarball import CondaTarBZ2 as _CondaTarBZ2, libarchive_enabled
File "C:\Users\alexk\Anaconda3\lib\site-packages\conda_package_handling\tarball.py", line 11, in
import libarchive
File "C:\Users\alexk\Anaconda3\lib\site-packages\libarchive__init__.py", line 1, in
from .entry import ArchiveEntry
File "C:\Users\alexk\Anaconda3\lib\site-packages\libarchive\entry.py", line 6, in
from . import ffi
File "C:\Users\alexk\Anaconda3\lib\site-packages\libarchive\ffi.py", line 27, in
libarchive = ctypes.cdll.LoadLibrary(libarchive_path)
File "C:\Users\alexk\Anaconda3\lib\ctypes__init__.py", line 434, in LoadLibrary
return self._dlltype(name)
File "C:\Users\alexk\Anaconda3\lib\ctypes__init__.py", line 356, in init
self._handle = _dlopen(self._name, mode)
OSError: [WinError 127] The specified procedure could not be found
and also a error window pops up saying:
The procedure entry point gzdirect could not be located in the dynamic link library C:\User\\Anaconda3\Library\bin\libxml2.dll
I am answering quite lately but I had a similar issue recently and this post was the closest to my issue (and had no answers).
The issue for me though was that I was trying to communicate with matlab from c++ code (using visual c++ in visual studio).
After searching a long time, I discovered that gzdirect came from zlib1.dll and not libxml.
What caused this issue for me was that I added the path to the matlab dlls at the end of my path environnment variable and because of that, a zlib from my system was used instead of Matlab Zlib.
All I had to do was to add the path to Matlab's DLL at the start of my path and not at the end.

How to fix "AttributeError: 'module' object has no attribute 'SOL_UDP'" error in Python Connector Mule

I'm trying to execute a basic script to return Cisco Config File as a JSON Format, and I have a success process over Python2.7.16 and Python 3.7.3, but when I'm trying to execute the same script over Python Connector for Mule ESB I receive the error refered in the title of this thread.
This is for a Mule feature, the Python connector script in this tool, works with a Jython 2.7.1, and is loaded as a library for the Mule.
I expect the output as a JSON file but actual output is:
Root Exception stack trace:
Traceback (most recent call last):
File "<script>", line 2, in <module>
File "C:\Python27\Lib\site-packages\ciscoconfparse\__init__.py", line 1, in <module>
from ciscoconfparse import *
File "C:\Python27\Lib\site-packages\ciscoconfparse\ciscoconfparse.py", line 17, in <module>
from models_cisco import IOSHostnameLine, IOSRouteLine, IOSIntfLine
File "C:\Python27\Lib\site-packages\ciscoconfparse\models_cisco.py", line 8, in <module>
from ccp_util import _IPV6_REGEX_STR_COMPRESSED1, _IPV6_REGEX_STR_COMPRESSED2
File "C:\Python27\Lib\site-packages\ciscoconfparse\ccp_util.py", line 16, in <module>
from dns.resolver import Resolver
File "C:\Python27\Lib\site-packages\dns\resolver.py", line 1148, in <module>
_protocols_for_socktype = {
AttributeError: 'module' object has no attribute 'SOL_UDP'
The only thing I had to do was comment that line in the script resolver.py and in this way the script on Anypoint Studio ran smoothly.
Thanks for your help, I hope that this helps to other people.
The problem appears to be that you are trying to execute a script that depends on a different python package. Mule supports executing python scripts using the Java Jython implementation but it probably doesn't know about pyhton packages dependencies.

Lxml import issues when using Scrapy

I am trying to use Scrapy with Anaconda/Miniconda on Windows 10. Installation goes fine, but trying to actually run Scrapy gives the following error:
Traceback (most recent call last):
File "C:\ProgramData\Miniconda3\Scripts\scrapy-script.py", line 6, in <module>
from scrapy.cmdline import execute
File "C:\ProgramData\Miniconda3\lib\site-packages\scrapy\__init__.py", line 34, in <module>
from scrapy.spiders import Spider
File "C:\ProgramData\Miniconda3\lib\site-packages\scrapy\spiders\__init__.py", line 10, in <module>
from scrapy.http import Request
File "C:\ProgramData\Miniconda3\lib\site-packages\scrapy\http\__init__.py", line 11, in <module>
from scrapy.http.request.form import FormRequest
File "C:\ProgramData\Miniconda3\lib\site-packages\scrapy\http\request\form.py", line 11, in <module>
import lxml.html
File "C:\ProgramData\Miniconda3\lib\site-packages\lxml\html\__init__.py", line 53, in <module>
from .. import etree
ImportError: DLL load failed: The specified module could not be found.
I have tried reinstalling Scrapy, lxml, and Anaconda itself (this time, I'm using a clean install of Miniconda), as well as downloading unofficial lxml build from https://www.lfd.uci.edu/~gohlke/pythonlibs/, as suggested in one of the answers on Stack Overflow, but the problem persists. I have also done this on an Amazon AWS EC2 instance started from scratch, but I'm getting the same issue.
It seems to be something relatively common, but I couldn't find an answer that would work for me. What's an appropriate way to address this? Is it just about lxml, or is there something else causing this problem?

cannot import name PyMCObjects when import pymc

I have pymc installed, and I am now trying to import it in my code. However,
First when I do import pymc, I got the error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "//anaconda/lib/python2.7/site-packages/pymc-2.3.3-py2.7-macosx-10.9-x86_64.egg/pymc/__init__.py", line 30, in <module>
from .CommonDeterministics import *
File "//anaconda/lib/python2.7/site-packages/pymc-2.3.3-py2.7-macosx-10.9-x86_64.egg/pymc/CommonDeterministics.py", line 21, in <module>
from .utils import safe_len, stukel_logit, stukel_invlogit, logit, invlogit, value, find_element
File "//anaconda/lib/python2.7/site-packages/pymc-2.3.3-py2.7-macosx-10.9-x86_64.egg/pymc/utils.py", line 14, in <module>
from . import flib
ImportError: numpy.core.multiarray failed to import
which can be fixed by manually import numpy.core.multiarray, but then, when I try again to import pymc, I got another error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "//anaconda/lib/python2.7/site-packages/pymc-2.3.3-py2.7-macosx-10.9-x86_64.egg/pymc/__init__.py", line 30, in <module>
from .CommonDeterministics import *
File "//anaconda/lib/python2.7/site-packages/pymc-2.3.3-py2.7-macosx-10.9-x86_64.egg/pymc/CommonDeterministics.py", line 13, in <module>
from . import PyMCObjects as pm
ImportError: cannot import name PyMCObjects
I googled around, and the solutions to similar problems are either:
In case that's related to the installation of pymc, force using the 32-bit instead of 64. However, this answer is for Windows users, and I have OS X 10.9 (Mavericks).
In other cases, it's usually due to a circular dependency (for example, here), which I don't think is the case here.
My guess is that something is wrong with the package flib, but I couldn't figure out what. I would appreciate any answer/hint on this problem. Thanks in advance!
Update (July-4-2014)
Thanks, Chris! I rebuilt my pymc using the conda build by doing conda install -c https://conda.binstar.org/tobeplugged pymc, and now when I do import pymc, a different error message appears:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "//anaconda/lib/python2.7/site-packages/pymc-2.3.3-py2.7-macosx-10.9-x86_64.egg/pymc/__init__.py", line 44, in <module>
from . import CommonDeterministics
ImportError: cannot import name CommonDeterministics
As Chris pointed out (see comments below), the problem(s) is being looked at here. The problem seems to have to do with the version of gcc (version 4.9). I will try to rebuild my gcc with the older version (4.8.2) later today to see if that will solve the problem for OS X 10.9 (Mavericks). Otherwise, I believe people can wait a little bit for the pymc team to solve this problem, too.

Cannot import "logging" module using Jython in embedded Jetty -> ImportError: no os specific module found

I'm trying to use Jython (embedded) in a Jetty server (all through Maven) to invoke a simple Python script.
My script works fine as long as I don't try to use any of the standard library's such as 'logging.' Whenever I try to import one of the standard library's it fails with the exception "ImportError."
The exception I get is:
File "<string>", line 1, in <module>
File "c:\home\work\sample\content\helloworld\helloworld.py", line 10, in <module>
import logging
File "c:\home\work\sample\content\Lib\logging\__init__.py", line 29, in <module>
import sys, os, types, time, string, cStringIO, traceback
File "c:\home\work\sample\content\Lib\os.py", line 119, in <module>
raise ImportError, 'no os specific module found'
ImportError: no os specific module found
at org.python.core.PyException.fillInStackTrace(PyException.java:70)
at java.lang.Throwable.<init>(Throwable.java:181)
at java.lang.Exception.<init>(Exception.java:29)
at java.lang.RuntimeException.<init>(RuntimeException.java:32)
at org.python.core.PyException.<init>(PyException.java:46)
at org.python.core.PyException.doRaise(PyException.java:200)
at org.python.core.Py.makeException(Py.java:1159)
at org.python.core.Py.makeException(Py.java:1163)
at os$py.f$0(c:\home\work\sample\content\Lib\os.py:692)
at os$py.call_function(c:\home\work\sample\content\Lib\os.py)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.imp.createFromCode(imp.java:325)
at org.python.core.imp.createFromPyClass(imp.java:144)
at org.python.core.imp.loadFromSource(imp.java:504)
at org.python.core.imp.find_module(imp.java:410)
at org.python.core.imp.import_next(imp.java:620)
at org.python.core.imp.import_first(imp.java:650)
at org.python.core.imp.import_name(imp.java:741)
at org.python.core.imp.importName(imp.java:791)
at org.python.core.ImportFunction.__call__(__builtin__.java:1236)
at org.python.core.PyObject.__call__(PyObject.java:367)
at org.python.core.__builtin__.__import__(__builtin__.java:1207)
at org.python.core.__builtin__.__import__(__builtin__.java:1190)
at org.python.core.imp.importOne(imp.java:802)
at logging$py.f$0(c:\home\work\sample\content\Lib\logging\__init__.py:1372)
at logging$py.call_function(c:\home\work\sample\content\Lib\logging\__init__.py)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.imp.createFromCode(imp.java:325)
at org.python.core.imp.createFromPyClass(imp.java:144)
at org.python.core.imp.loadFromSource(imp.java:504)
at org.python.core.imp.find_module(imp.java:410)
at org.python.core.imp.import_next(imp.java:620)
at org.python.core.imp.import_first(imp.java:650)
at org.python.core.imp.import_name(imp.java:741)
at org.python.core.imp.importName(imp.java:791)
at org.python.core.ImportFunction.__call__(__builtin__.java:1236)
at org.python.core.PyObject.__call__(PyObject.java:367)
at org.python.core.__builtin__.__import__(__builtin__.java:1207)
at org.python.core.__builtin__.__import__(__builtin__.java:1190)
at org.python.core.imp.importOne(imp.java:802)
at helloworld.helloworld$py.f$0(c:\home\work\sample\content\helloworld\helloworld.py:19)
at helloworld.helloworld$py.call_function(c:\home\work\sample\content\helloworld\helloworld.py)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.imp.createFromCode(imp.java:325)
at org.python.core.imp.createFromPyClass(imp.java:144)
at org.python.core.imp.loadFromSource(imp.java:504)
at org.python.core.imp.find_module(imp.java:410)
at org.python.core.PyModule.impAttr(PyModule.java:109)
at org.python.core.imp.import_next(imp.java:622)
at org.python.core.imp.import_name(imp.java:761)
at org.python.core.imp.importName(imp.java:791)
at org.python.core.ImportFunction.__call__(__builtin__.java:1236)
at org.python.core.PyObject.__call__(PyObject.java:367)
at org.python.core.__builtin__.__import__(__builtin__.java:1207)
at org.python.core.imp.importFromAs(imp.java:869)
at org.python.core.imp.importFrom(imp.java:845)
at org.python.pycode._pyx1.f$0(<string>:1)
at org.python.pycode._pyx1.call_function(<string>)
at org.python.core.PyTableCode.call(PyTableCode.java:165)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1197)
at org.python.core.Py.exec(Py.java:1241)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:138)
My scripts looks like:
from java.util import Random
from java.util import Date
import sys
print(sys.path)
print(sys.builtin_module_names)
import logging
logging.basicConfig(level=logging.WARNING)
logger1 = logging.getLogger('aaa')
logger1.warning('************* This message comes from one module')
def say_hello():
return 'hello world1'
I've tried the following so far but nothing has worked:
Include the zip of the 'Lib' directory in my classpath
Hard-coding the 'Lib' path when i setup the interpreter.
If I do it directly from the interactive Jython shell the script works fine (and a logging message appears).
Thanks.
KJQ
I think for now i've found an answer to my own question...
Basically, i knew it had something to do with my paths but could not figure out how to do them.
I ended up creating a "standalone" version of the Jython jar through the installer (and it includes the /Libs directory) and using that.