I raised the following issue with the P4A guys but I think (hope) that you may be of greater help.
Perhaps you have encountered this problem before. Here I copy and paste.
Thanks, Enoch.
cryptography is an essential module in my kivy / twisted / pyOpenSSL based app.
Building finally succeeded (it wasn't straightforward) but now we are run time testing.
Thanks to a tip from "tshirtman" I had a meaningful rpdb interactive session as follows:
$ telnet 192.168.1.254 4444
Trying 192.168.1.254...
Connected to 192.168.1.254.
Escape character is '^]'.
> /home/enoch/private/gsld/build/bdist.android-armeabi-v7a/gsld/main.py(38)<module>()
(Pdb) import cryptography
(Pdb) cryptography.__file__
'/data/data/info.gencon.gsld/files/app/lib/python2.7/site-packages/cryptography/__init__.pyo'
(Pdb) os.listdir('/data/data/info.gencon.gsld/files/app/lib/python2.7/site-packages/cryptography')
['utils.pyo', '__init__.pyo', '__about__.pyo', 'fernet.pyo', 'exceptions.pyo', 'x509', 'hazmat']
(Pdb) import cryptography.hazmat
(Pdb) import cryptography.x509
***** ImportError: cannot import name certificate_transparency**
(Pdb) os.listdir('/data/data/info.gencon.gsld/files/app/lib/python2.7/site-packages/cryptography/x509')
['general_name.pyo', 'name.pyo', 'oid.pyo', '__init__.pyo', 'extensions.pyo', 'base.pyo', 'certificate_transparency.pyo']
This ImportError indicates that python was not able to get the module code! Not that a file is missing...
Since the same cryptography module (github master) works well in Linux I tend to believe that our stale Python version 2.7.2 is to blame... (Ubuntu is using 2.7.14). Or, do you have another idea?
You're not the first person to run into an issue importing cryptography.x509.certificate_transparency, however I have no clue what the issue is :-(
cryptography now works in my Python-for-Android setting:
The problem was that all its shared objects (_padding.so, _openssl.so, _constant_time.so), as well as CFFI's _cffi_backend.so, could not find at run-time the libpython2.7.so.
What helped was building those shared objects with extra LDFLAGS arguments:
-lpython and -rpath=/data/data/_app-name_/lib (where libpython2.7.so resides).
It would have better if ImportError advises why it failed importing.
@wexi
What helped was building those shared objects with extra LDFLAGS arguments:
-lpython and -rpath=/data/data/app-name/lib (where libpython2.7.so resides).
Sorry for my incompetence, but could you write the full command to build them, please.
I have the similar issue..
@wexi Can you share more detail about what you did in regards to LDFLAGS to workaround this problem?
Was getting the same importerror in docker using pipenv but thx to @wexi comment I fixed it by building CFFI from source as recommended in cffi docs http://cffi.readthedocs.io/en/latest/installation.html#platform-specific-instructions:
virtualenv ~/venv
cd ~/path/to/sources/of/cffi
~/venv/bin/python setup.py build --force # forcing a rebuild to make sure
~/venv/bin/python setup.py install
For me that meant:
RUN wget https://pypi.python.org/packages/e7/a7/4cd50e57cc6f436f1cc3a7e8fa700ff9b8b4d471620629074913e3735fb2/cffi-1.11.5.tar.gz#md5=ac8492f4ad952360737413e82d661908 \
&& tar -vxf cffi-1.11.5.tar.gz \
&& cd cffi-1.11.5 && python setup.py build --force \
&& python setup.py install
Most helpful comment
@wexi
Sorry for my incompetence, but could you write the full command to build them, please.
I have the similar issue..