Protobuf for Python and protoc versions match still assertion fails - string

I am getting this error:
./google/protobuf/generated_message_util.h:86: const string&
google::protobuf::internal::GetEmptyStringAlreadyInited(): Assertion
`empty_string_ != __null' failed.
I have been trying to fix this all day long.
So the flow in my project goes like this:
I have a C++ project that I compile using CMake on Ubuntu 16.10. After some processing I want to send the data to a Python script that uses Keras for machine learning.
Now both of these scripts work perfectly independently. I wanted to send the data directly to the Python script. So I have embedded Python in C++ by referring this link
This is again working for a Python script that does not import keras.
Now when I import keras in this Python script, I get the above error, though both of them work properly independetly.
First I had got an error for the mismatch of libprotobuf and protoc versions which looked like:
Using TensorFlow backend.
[libprotobuf FATAL google/protobuf/stubs/common.cc:67] This program requires version 3.5.0 of the Protocol Buffer runtime library,
but the installed version is 3.0.0. Please update your library. If
you compiled the program yourself, make sure that your headers are
from the same version of Protocol Buffers as your link-time library.
(Version verification failed in "google/protobuf/descriptor.pb.cc".)
terminate called after throwing an instance of 'google::protobuf::FatalException'
what(): This program requires version 3.5.0 of the Protocol Buffer runtime library, but the installed version is 3.0.0. Please
update your library. If you compiled the program yourself, make sure
that your headers are from the same version of Protocol Buffers as
your link-time library. (Version verification failed in
"google/protobuf/descriptor.pb.cc".)
Aborted (core dumped)
I had installed protoc using apt-get (latest available on apt-get is 3.0.0) as I found out on one of the answers that you need not have protoc 3.5.0 for it to work. pip3 install protobuf installs protobuf 3.5.0 which resulted in the mismatch error message.
So I uninstalled this Python protobuf version and installed the older version using pip3 install protobuf==3.0.0. This removed the mismatch error message.
But now I am getting the aforementioned error message. I have also figured out that the error message is occuring due to Tensorflow dependency of Keras
How do I fix this?
Please help

Related

Can’t make python work in conda environment (GLIBC not found)

I'm trying to set up a conda environment with python 3.6 on a remote server working on CentOS. The installation goes well, but once I try to execute python I get the following message python: /lib64/libc.so.6: version 'GLIBC_2.15' not found. I noticed that for other python version older than 3.4 this doesn't happen.
Given this, I tried installing glibc before python, but after installing python 3.6 and trying to run it, now I get Segmentation fault (core dumped).
Note that I don't have permissions to update conda and that the version the server is using is 4.4.7, so I haven't tried updating it. However, I had previously set an environment without any problem. After I tried to install a package my jupyter notebooks wouldn't work so I removed the environment.
What would be the new system and the old one.
The old system -- the remove server running CentOS, has GLIBC that is older than 2.15.
The new system -- the one on which your Python 3.6 was compiled, used GLIBC-2.15 (or newer).
You need to either find a Python 3.6 build which is targeted to your version of CentOS, or you need to compile one yourself on a system with GLIBC matching whatever is installed on your remote server.
P.S. Saying "server running CentOS" is like saying "system running Windows" (i.e. not saying much). Which version of CentOS?

Why didn't I receive cryptography.hazmat.bindings._padding when installing cryptography with StaSh?

I am using Pythonista for iOS and installed the cryptography package using the latest version of StaSh. It looked like there was an issue during installation but it still seemed to be successful:
Extracting archive file ...
Archive extracted.
Running setup file ...
TypeError('expected string or bytes-like object',)
Failed to run setup.py
Fall back to directory guessing ...
Package installed: cryptography
However, when I try to import Fertnet from cryptography.fertnet I get a ModuleNotFoundError. Apparently I'm missing cryptography.hazmat.bindings._padding. Does anyone have any idea why I'm not getting that module?
The cryptography module is partly written in C.
Those parts have to be compiled into shared libraries. The libraries are named _constant_time, _openssl and _padding and they should be located in hazmat/bindings.
AFAICT PyPI only carries compiled packages for linux, windows and macOS but not for IOS.
So my guess is that setup.py fails because it cannot compile those libraries.

Sundials installed but not running in python with assimulo

Cheerio,
I am trying to use Assimulo 2.9. on a Mac OS X. For that I downloaded and installed sundials via cmake by creating a builddir to the Download file and ../Downloads/sundials-2.7.0 running
$cmake ../Downloads/sundials-2.7.0
$make
$make install
This should install everything in /usr/local.
It gives me no error warning when doing this. But when I am trying to use assimulo in python, following error message occurs:
from .sundials import IDA, CVode
ImportError: No module named sundials
Any suggestions?
Thank you very much.
The trick was to install everything through homebrew and get the missing sundials.so file. It seems that the current assimulo-2.9 distribution on pypi does not provide this shared object library and therefore triggers this error message.
I got the same error, in Anaconda(Ubuntu 18.04). I installed pyfmi first, and then installed the dependencies (assimulo, sundials) according to the error message. After everything was installed, the pyfmi was not working by running an fmu example.
But i uninstalled all the related software. Then i reinstalled everything with certain order. I found the order of installation matters, which are: sundials --> assimulo --> pyfmi.
Everything is good now.

Anaconda Python for Gurobi 6.0.4 installation _Py_FalseStruct error

In order to run an optimization problem we set up Gurobi 6.0.4 together with
Anaconda (Version 2.2.0) Python (Python 2.7.9.) on
Linux CentOS release 6.6 (Final) with the 2.6.32-504.16.2.el6.x86_64 Kernel
Following the installation guidelines of Gurobi (listed here: http://www.gurobi.com/documentation/6.0/quickstart_linux.pdf)
everything worked out in the first step. Gurobi was installed, could obtain a license. Also the PATH variables have been set (in the .bashrc) according to the manual, with a little extension for the referal to anaconda python (and not the other local Versions of python (being 2.7 and 3.4):
export GUROBI_HOME="/opt/gurobi604/linux64"
export PATH="${PATH}:${GUROBI_HOME}/bin:${PATH}:opt/anaconda/bin"
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${GUROBI_HOME}/lib"
Following the procedure we executed: python2.7 setup.py install in the respective directory /opt/gurobi604/linux64. After this usually you could run the import gurobipy command in the python interpreter wihtout errors. For older Versions of Gurobi (as 5.6.3) this works out very well.
For 6.0.4 though we constantly receive the error:
ImportError: /opt/anaconda/lib/python2.7/site-packages/gurobipy/gurobipy.so: undefined symbol: _Py_FalseStruct
This is very reproducible, no matter if we put anaconda also in the global path, and check the bash for any overwriting of the environment variables, which is not the case.
On Windows 8 the Gurobi 6.0.4 and Anaconda Python 2.2.0 work together without any problems.
Also applying hints from here: Python Module Error on Linux did not work out.
Did anyone else experience these problems with this tooling combination? thx.
The error message indicates that you use the Python module for version 3.4 in your Python 2.7 package directory. This can happen if you do not clean your Python module build directory between builds. Please try the following:
Completely remove the 2.7 package from your Python 2.7 installation (e.g. remove /opt/anaconda/lib/python2.7/site-packages/gurobipy)
Completely remove the Python module build directory from your Gurobi installation (e.g. /opt/gurobi604/linux64/build)
Re-run the build process for the Python 2.7 module (e.g. run "python2 setup.py install" in /opt/gurobi604/linux64)
Please note that CentOS is currently a non-supported platform for Gurobi.
Thank you for the hint, I think we tried that, but did not finish the procedure in this way. We tried to clean the system but in that particular case still hat both python Versions (due to other applications that use 3.4) on the machine. Our solution in this case was just to reinstall everything clean on a Ubuntu 14.04 VM. Since then no further problems occured. (I know not the cleanest solution.)
We had some similar issues when we updated to Gurobi 6.5, but that could be solved when corrctly addressing the usual path issues.
Thank you in any case for the reply, I think this really will help us with the next, then clean deployment :-)

Any tips on compiling PyQt for Centos 5.5?

I have installed a bunch of qt packages - qt, qt-devel, qt4, qt4-devel, sip but can't get latest PyQt4 to compile.
I've pointed the configure script at my qt4lib as such
python configure.py -q /usr/lib64/qt4/bin/qmake --verbose
but getting errors like
DBus v1 does not seem to be installed.
cfgtest_QtHelp.cpp:1:25: error: qhelpengine.h: No such file or directory
sip: /mnt/hgfs/rnp_repos/PyQt-x11-gpl-4.8.1/sip/QtCore/qabstractitemmodel.sip:156: syntax error
Error: Unable to create the C++ code.
EDIT: Found out that SIP v4.11.2 is required for PyQt 4.8 but still can't make without errors. At least python configure.py finishes now.
Any tips?
Grab the PyQt4 SRPM from Fedora and rebuild using mock. You may need to look a few versions back for one that will compile against the version of Qt 4 in CentOS.
I've just successfully compiled PyQt 4.8 on Centos 5.5. I went down the route of building Qt4 from source - using qt-everywhere-opensource-src-4.7.1.tar.gz from Nokia.
Had to obtain various *-devel packages before Qt's ./configure would complete - see http://doc.qt.nokia.com/4.7/requirements-x11.html (don't worry about the version numbers being slightly lower than required).
Also I used Python 2.6 from the EPEL 5 repository (python26-devel). Just remember when building PyQt to run python26 configure.py (and not the default Python). I don't know if this will improve your mileage in building PyQt but we're porting an application from Windows which was already using 2.6 so this route was necessary for me.
Not going to post my entire .bash_history here (much trial and error!) but if you're trying this and get stuck please ask a question.

Resources