ImportError: cannot import name certificate_transparency

Stone Zhong stone.zhong at gmail.com
Thu Jan 17 03:10:36 EST 2019


Hi,

My program depend on package oci, I am using the following command to install it:
pip install oci

Everything works perfect in virtualenv (I am still using python 2.7.x)

Now I am creating a zip file from the libraries:

pip install oci -t ~/temp/oci
cd ~/temp/oci
zip -r ~/temp/oci.zip .

Test A) PYTHONPATH=~/temp/oci myapp.py
Test B) PYTHONPATH=~/temp/oci.zip myapp.py

Test A) works fine and Test B) failed with error "ImportError: cannot import name certificate_transparency"

It seems we have some so file there:
./cryptography/hazmat/bindings/_padding.so
./cryptography/hazmat/bindings/_openssl.so
./cryptography/hazmat/bindings/_constant_time.so
./_cffi_backend.so

I also tested below:

mytest.py:
...
from cryptography.hazmat.bindings._constant_time import lib

PYTHONPATH=~/temp/oci.zip mytest.py

I end up with error "ImportError: No module named _constant_time"

So my guess is, package with shared lib (.so files) cannot be put into zip file, is it a bug in python zipimport?

The reason I have to use a zip file is, I need it in a spark job, I cannot do "virtualenv" in pyspark, have to use --py-files to pass the zip file for all dependent packages.

Thanks,
Stone



More information about the Python-list mailing list