I find a way which is not recommended, but it do solve the problem.
For example, I use the third pacakge openpyxl
to show how to do that.
Every machine is not allowed to install modules at will, but you can upload any file.
Find a networked machine,execute pip install openpyxl
cd your pacakge dir, on my machine it is cd /usr/lib/python2.7/site-packages/
zip the dir or file updated recently. you can see them by using ls -ltr | tail -10
drwxr-xr-x 3 root root 4096 Jan 12 11:21 shadowsocks
drwxr-xr-x 2 root root 4096 Jan 12 11:21 shadowsocks-2.8.2-py2.7.egg-info
-rw-r--r-- 1 root root 12462 Apr 21 10:38 jdcal.py
-rw-r--r-- 1 root root 13004 Apr 21 10:38 jdcal.pyc
drwxr-xr-x 2 root root 4096 Apr 21 10:38 jdcal-1.4.1.dist-info
drwxr-xr-x 3 root root 4096 Apr 21 10:38 et_xmlfile
drwxr-xr-x 2 root root 4096 Apr 21 10:38 et_xmlfile-1.0.1-py2.7.egg-info
drwxr-xr-x 20 root root 4096 Apr 21 10:38 openpyxl
drwxr-xr-x 2 root root 4096 Apr 21 10:38 openpyxl-2.6.4-py2.7.egg-info
We will find that openpyxl
and its dependencies jdcal
,et_xmlfile
so I zip file by order zip -qr openpyxl-2.6.4.zip jdcal.py jdcal.pyc et_xmlfile openpyxl
Then upload this file to an unconnected machine to use by:
>>> import os,sys
>>> sys.path.insert(0,'/root/openpyxl-2.6.4.zip')
>>> import openpyxl
it success.