Su un piccolo dispositivo Linux incorporato con spazio limitato, sto cercando di posizionare la grande libreria BotoCore (10SB) Amazon (AWS) (https://github.com/boto/botocore) in un file zip per comprimerla e quindi importarla nei miei script Python utilizzando zipimport come descritto in PEP273 (https://www.python.org/dev/peps/pep-0273/).Python PEP 273 e Amazon BotoCore
ho modificato il mio script di avere le seguenti righe all'inizio:
## Use zip imports
import sys
sys.path.insert(0, '/usr/lib/python2.7/site-packages/site-packages.zip')
Le site-packages zip file solo ha botocore in esso e site-packages directory stessa ha gli altri moduli che uso, ma esclusi botocore, in esso.
Ecco una lista di directory:
/usr/lib/python2.7/site-packages >> ls -rlt
total 1940
-rw-rw-r-- 1 root root 32984 Jun 8 12:22 six.pyc
-rw-r--r-- 1 root root 119 Jun 11 07:43 README
drwxrwxr-x 2 root root 4096 Jun 11 07:43 requests-2.4.3-py2.7.egg-info
drwxrwxr-x 2 root root 4096 Jun 11 07:43 six-1.9.0-py2.7.egg-info
drwxrwxr-x 2 root root 4096 Jun 11 07:43 python_dateutil-2.4.2-py2.7.egg-info
drwxrwxr-x 2 root root 4096 Jun 11 07:43 jmespath-0.7.0-py2.7.egg-info
-rw-rw-r-- 1 root root 2051 Jun 11 07:44 pygtk.pyc
-rw-rw-r-- 1 root root 1755 Jun 11 07:44 pygtk.pyo
-rw-rw-r-- 1 root root 8 Jun 11 07:44 pygtk.pth
drwxrwxr-x 2 root root 4096 Jun 11 07:44 futures-2.2.0-py2.7.egg-info
drwxrwxr-x 3 root root 4096 Jun 11 07:44 gtk-2.0
drwxrwxr-x 3 root root 4096 Jun 11 07:44 requests
drwxrwxr-x 3 root root 4096 Jun 11 07:44 dbus
drwxrwxr-x 3 root root 4096 Jun 11 07:44 dateutil
drwxrwxr-x 2 root root 4096 Jun 11 07:44 jmespath
drwxrwxr-x 3 root root 4096 Jun 11 07:44 concurrent
drwxrwxr-x 2 root root 4096 Jun 11 07:44 futures
drwxrwxr-x 2 root root 4096 Jun 12 10:42 gobject
drwxrwxr-x 2 root root 4096 Jun 12 10:42 glib
-rwxr-xr-x 1 root root 5800 Jun 12 10:42 _dbus_glib_bindings.so
-rwxr-xr-x 1 root root 77680 Jun 12 10:42 _dbus_bindings.so
-rwxr-xr-x 1 root root 1788623 Jun 12 11:39 site-packages.zip
Ed ecco il contenuto di quel file zip:
mio problema è che posso importare boto3 e l'importazione botocore basta trovare, ma quando io cerco di utilizzare alcuni metodi API in esso contenute, ottengo eccezioni in questo modo:
>> Unknown component: enpoint_resolver
o
>> Unable to load data for: aws/_endpoints!
Se rimuovo il file zip dopo averlo decompresso nella directory dei siti del sito e riavviato, il mio script funziona correttamente.
Come posso sfruttare le importazioni zipfile per comprimere questa enorme libreria? Grazie!
Omg, offre il tuo intero rappresentante! : O – Zizouz212
Qual è la rep quando si desidera una risposta? – PhilBot
Immagino ... ma ancora! – Zizouz212