Linux Test Android Python 2.7 Automatic Packing Environment

1, environment

CentOS 6.4
Preface: CentOS 6.4 system comes with version 2.6.6 of Python

2. Download files

Pthon: https://www.python.org/downloads/    
Version: python-2.7.3
setuptools: https://pypi.python.org/pypi/setuptools#downloads  
Version: setuptools-0.6c11
pip official website: https://pypi.python.org/pypi/pip#downloads
Version: pip-1.5.6.tar.gz
Pmongo: https://pypi.python.org/pypi/pymongo#downloads
Version: pymongo-2.7.2.tar.gz
xlrd: https://pypi.python.org/pypi/xlrd
Version: xlrd-0.9.3.tar.gz
xlwt official website: https://pypi.python.org/pypi/xlwt
Version: xlwt-0.7.5.tar.gz
xlutils official website: https://pypi.python.org/pypi/xlutils
Version: xlutils-1.7.1.tar.gz
cx_Oracle: https://pypi.python.org/pypi/cx_Oracle/5.1.3
Version: cx_Oracle-5.1.3.tar.gz

3. Install Python 2.7.3

  • 1. View the python version of the system
[root@vm4 webapps]# python -V
Python 2.6.6

yum install gcc
yum install zlib
yum install zlib-devel
yum install freetype freetype-devel

yum install libpng-devel
yum install openssl -y

yum install openssl-devel -y
yum install -y libstdc++

yum groupinstall "Development tools"

yum install libjpeg libjpeg-devel zlib zlib-devel freetype freetype-devel lcms lcms-devel
  • 2. Unzip and install python
[root@vm4 logs]#cd /usr
[root@vm4 usr]# mkdir -p python
[root@vm4 usr]# cd python/
//Files to be downloadedPython-2.7.3.tgz Upload to python Inside folder
[root@vm4 python]#tar -zvxf Python-2.7.3.tgz
[root@vm4 python]# cd Python-2.7.3
[root@vm4 Python-2.7.3]# ./configure --prefix=/usr/local/python2.7.3
[root@vm4 Python-2.7.3]# make
[root@vm4 Python-2.7.3]# make install
  • 3. Directory after successful installation
[root@vm4 Python-2.7.3]# ll /usr/local/python2.7.3/
//Total 16
drwxr-xr-x 2 root root 4096 03-21 10:12 bin
drwxr-xr-x 3 root root 4096 03-21 10:07 include
drwxr-xr-x 4 root root 4096 03-21 10:07 lib
drwxr-xr-x 3 root root 4096 03-21 10:07 share
  • 4. Establishing Software Links
[root@vm4 Python-2.7.3]# ln -s /usr/local/python2.7.3/bin/python /usr/bin/python2.7.3
[root@vm4 Python-2.7.3]# python2.7.3
Python 2.7.3 (default, Mar 21 2013, 10:06:48)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2

Note: Do not make soft chain here, wait for backup before making soft chain.
If an operation is performed
[root@vm4 Python-2.7.3]#ln -s /usr/python/python2.7.3/bin/python /usr/bin/python
Modifying the old version's ln pointing may affect the use of yum, which is compatible with Python version 2.6. The soft-chain address here should be wrong. It should be ln-s/usr/local/python 2.7.3/bin/python/usr/bin/python (not yet implemented), and Python is installed successfully.

4. Install python-devel

[root@vm4 python]# yum install python-devel
Installed:
python-devel.x86_64 0:2.6.6-52.el6
Dependency Updated:
python.x86_64 0:2.6.6-52.el6 python-
libs.x86_64 0:2.6.6-52.el6
Complete!

Note: Due to the python-devel problem, it is recommended that Python use the default version 2.6.6. The above is just how to install python.

5. Install setuptools

Note: setuptools can only be installed after python has been installed successfully

  • 1. Upload the downloaded files to setuptools-0.6c11.tar.gz to the python folder
  • 2. Unzip and install setuptools-0.6c11
[root@vm4 python]# tar -zxvf setuptools-0.6c11.tar.gz
[root@vm4 setuptools-0.6c11]# cd setuptools-0.6c11
[root@vm4 setuptools-0.6c11]# Python-2.7.3 setup.py install

Return the following to indicate successful installation:

Installed /usr/python/Python-2.7.3/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg
Processing dependencies for setuptools==0.6c11
Finished processing dependencies for setuptools==0.6c11
  • 3. Establishing Soft Links
[root@vm4 setuptools-0.6c11]#ln -s /usr/local/python-2.7.3/bin/easy_install /usr/bin/easy_install-2.7.3
  • 4, test
[root@vm4 setuptools-0.6c11]#easy_install2.7.3 numpy

6. Installing pip

  • 1. Upload the downloaded file to the python folder pip-1.5.6.tar.gz
  • 2. Decompress and install pip-1.5.6
[root@vm4 python]#tar -zxvf pip-1.5.6
[root@vm4 python]# cd pip-1.5.6
[root@vm4 pip-1.5.6]# Python-2.7.3 setup.py install

Return the following to indicate successful installation:

Installed /usr/python/Python-2.7.3/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg
Processing dependencies for pip==1.5.6
Finished processing dependencies for pip==1.5.6
  • 3. Establishing Soft Links
[root@vm4 pip-1.5.6]#ln -s /usr/local/python-2.7.3/bin/pip /usr/bin/pip-2.7.3
  • 4, test
[root@vm4 pip-1.5.6]#pip-2.7.3 install nose

One more step: pip install pillow (17.07.25, no need)

7. Install pymongo

When python operates on mongo, you need to install this plug-in

  • The first method is:
[root@vm4 python]# pip-2.7.3 install pymongo
  • The second method:

1. Download the file pymongo-2.7.2.tar.gz and upload it to python
2. Decompression Installation

[root@vm4 python]#tar -zxvf pymongo-2.7.2.tar.gz
[root@vm4 python]# cd pymongo-2.7.2
[root@vm4 pymongo-2.7.2]# Python-2.7.3 setup.py install

Return the following to indicate successful installation:
Installed /usr/python/Python-2.7.3/lib/python2.7/site-packages/pymongo-2.7.2-py2.7-linux-
x86_64.egg
Processing dependencies for pymongo==2.7.2
Finished processing dependencies for pymongo==2.7.2

8. Install xlrd, xlwt, xlutils

xlrd: python's third-party control to read data from excel;
xlwt: python writes data from excel as a third-party control.
xlutils: python uses xlrd, xlwt toolbox. If the installation is unsuccessful, it may be due to the need to install setuptools.

  • The first method is:
[root@vm4 python]# pip-2.7.3 install xlrd
[root@vm4 python]# pip-2.7.3 install xlwt
[root@vm4 python]# pip-2.7.3 install xlutils
  • The second method:

1. Download files xlrd-0.9.3.tar.gz, xlwt-0.7.5.tar.gz, xlutils-1.7.1.tar.gz and upload them to python.
2. Decompress and install xlrd

[root@vm4 python]# tar -zxvf xlrd-0.9.3.tar.gz
[root@vm4 python]# cd xlrd-0.9.3
[root@vm4 xlrd-0.9.3]# Python-2.7.3 setup.py install

3. Unzip and install xlwt

[root@vm4 python]# tar -zxvf xlwt-0.7.5.tar.gz
[root@vm4 python]# cd xlwt-0.7.5
[root@vm4 xlwt-0.7.5]# Python-2.7.3 setup.py install

4. Unzip and install xlutils

[root@vm4 python]# tar -zxvf xlutils-1.7.1.tar.gz
[root@vm4 python]# cd xlutils-1.7.1
[root@vm4 xlutils-1.7.1]# Python-2.7.3 setup.py install

9. Install cx_Oracle

When python operates oracle, you need to install this plug-in. Only after the Oracle client is installed can cx_Oracle be installed.

[root@vm4 python]# pip-2.7.3 install cx_Oracle
Downloading/unpacking cx-Oracle
Downloading cx_Oracle-5.1.3.tar.gz (104kB): 104kB downloaded
Running setup.py (path:/tmp/pip_build_root/cx-Oracle/setup.py) egg_info for package cx-Oracle
Installing collected packages: cx-Oracle
Running setup.py install for cx-Oracle
building 'cx_Oracle' extension
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/opt/oracle/instantclient_11_2/sdk/include -I/usr/include/python2.6 -c cx_Oracle.c -o build/temp.linux-x86_64-2.6-11g/cx_Oracle.o -DBUILD_VERSION=5.1.3
gcc -pthread -shared build/temp.linux-x86_64-2.6-11g/cx_Oracle.o -L/opt/oracle/instantclient_11_2/ -L/usr/lib64 -lclntsh -lpython2.6 -o build/lib.linux-x86_64-2.6-11g/cx_Oracle.so
Successfully installed cx-Oracle
Cleaning up...

Establishing Soft Links after Successful Installation

[root@localhost instantclient_11_2]# ln -s libclntsh.so.11.1 libclntsh.so
(After successful installation of the above package in/usr/lib64/python2.6/site-packages)

10. Problems encountered during installation (important)

  • 1. After installing Python 2.7.3, execute
1. [root@vm4 Python-2.7.3]#mv /usr/bin/python /usr/bin/python2.6.6
2. [root@vm4 Python-2.7.3]#ln -s /usr/local/python-2.7.3/bin/python /usr/bin/python

When yum is used again, an error is reported: It's possible that the above module does't match the current version of Python
Cause analysis: The default Python version of CentOS 6.4 system is 2.6.6, which needs to be upgraded to Python 2.7.3. Because yum package management is written in python, updating Python alone will cause yum to be unusable.
The main reason for this is that the newly installed Python does not have Packages on which YUM services depend.
Solution: Find the yum file and edit the py file

[root@Centos ~]# which yum
/usr/bin/yum
[root@Centos ~]# vi /usr/bin/yum

//take
#!/usr/bin/python
//Changed to:
#!/usr/bin/python2.6.6 

Then save OK.
In addition, there is also a possibility that yum can not be used, that is, under / usr/bin python, Python 2, Python 2.4 files must not be changed. In theory, yum is only based on Python language and has nothing to do with the version, but there are problems in the upgrade process.

  • 2. The following errors occurred during python operation:

python error: ImportError: No module named setuptools
The superficial meaning of this error prompt is that there is no module for setuptools, indicating that python lacks this module, so we just need to install it.
The module can solve this problem.
Solution: Install setuptools

  • 3. Error reporting when executing python script
[root@vm4 statistics]# Python-2.7.3 generator.py
Traceback (most recent call last):
File "generator.py", line 3, in <module>
import cx_Oracle
ImportError: No module named cx_Oracle

Solution: Install cx_Oracle

  • 4. [root@localhost site-packages]# pip install cx_Oracle error reporting:
Downloading/unpacking cx-Oracle
Downloading cx_Oracle-5.1.3.tar.gz (104kB): 104kB downloaded
Running setup.py (path:/tmp/pip_build_root/cx-Oracle/setup.py) egg_info for package cx-Oracle
Installing collected packages: cx-Oracle
Running setup.py install for cx-Oracle
building 'cx_Oracle' extension
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/opt/oracle/instantclient_11_2/sdk/include -I/usr/include/python2.6 -c cx_Oracle.c -o build/temp.linux-x86_64-2.6-11g/cx_Oracle.o -DBUILD_VERSION=5.1.3
gcc -pthread -shared build/temp.linux-x86_64-2.6-11g/cx_Oracle.o -L/opt/oracle/instantclient_11_2/ -L/usr/lib64 -lclntsh -lpython2.6 -o build/lib.linux-x86_64-2.6-11g/cx_Oracle.so
/usr/bin/ld: cannot find -lclntsh
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/cx-Oracle/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-ONXD3d-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_ext
building 'cx_Oracle' extension
creating build
creating build/temp.linux-x86_64-2.6-11g
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/opt/oracle/instantclient_11_2/sdk/include -I/usr/include/python2.6 -c cx_Oracle.c -o build/temp.linux-x86_64-2.6-11g/cx_Oracle.o -DBUILD_VERSION=5.1.3
creating build/lib.linux-x86_64-2.6-11g
gcc -pthread -shared build/temp.linux-x86_64-2.6-11g/cx_Oracle.o -L/opt/oracle/instantclient_11_2/ -L/usr/lib64 -lclntsh -lpython2.6 -o build/lib.linux-x86_64-2.6-11g/cx_Oracle.so
/usr/bin/ld: cannot find -lclntsh
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/cx-Oracle/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-ONXD3d-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/cx-Oracle
Storing debug log for failure in /root/.pip/pip.log

Solution: [root@localhost instantclient_11_2] Ln-S libclntsh.so.11.1 libclntsh.so

  • 5,
    When executing python scripts, report. / startup.sh: Permission denied
    Solution: Chmod u+x*.sh

  • 6,

[root@localhost statistics]# ./generator.py
Traceback (most recent call last):
File "./generator.py", line 3, in <module>
import cx_Oracle
ImportError: libaio.so.1: cannot open shared object file: No such file or directory

Solution: [root@localhost statistics] Yum install libaio

11. The relationship between Python and python-dev and boost.python

Many times, many people don't understand the relationship between Python and python-dev and boost.python. Python is the execution environment
If you want to call Python in c/c++, or Python calls C or c++, you need python-dev. boost.python just encapsulates python-dev. Many functions have the same function on both sides, that is to say, run1 can be used in python-dev.
Function, using boost.python's interface such as run2,boost.python encapsulation is more friendly and has been as exception handling.

1. Download Source Kit of PIL (because this package supports all platforms) Image - 1.1.7.tar.gz
http://effbot.org/downloads/Imaging-1.1.7.tar.gz

2. Decompression package tar-zxvf Image-1.1.7.tar.gz

3. Enter the decompressed directory cd Imaging-1.1.7

4,Build pakage: python setup.py build_ext -i

5. Testing; python selftest.py
Adding this step, vi setup.py modifies the JPEG path regardless of the test results above

6. Install python setup.py install

After doing the above, you can use import Image directly in the program to use the Image class in PIL!

JPEG_ROOT = "/usr/lib64/"
ZLIB_ROOT = "/usr/lib64/"


//For APK packages, first test. / aapt-v to see if it works.
http://blog.csdn.net/sole_cc/article/details/51415940
/lib64/libc.so.6: version `GLIBC_2.14' not found
strings /lib64/libc.so.6 | grep GLIBC
ll /lib64/libc.so.6


    1. wget http://ftp.gnu.org/gnu/glibc/glibc-2.15.tar.gz  
    2.    
    3. wget http://ftp.gnu.org/gnu/glibc/glibc-ports-2.15.tar.gz  
    4.    
    5. tar -xvf  glibc-2.15.tar.gz  
    6.    
    7. tar -xvf  glibc-ports-2.15.tar.gz  
    8.    
    9. mv glibc-ports-2.15 glibc-2.15/ports  
    10.    
    11. mkdir glibc-build-2.15   
    12.    
    13.    
    14. cd glibc-build-2.15  
    15.    
    16.    
    17. ../glibc-2.15/configure  --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin  
    18.    
    19.    
    20. make  
    21. make install  



./zipalign error yum install glibc.i686
yum install libstdc++.so.6
yum install zlib.i686

Keywords: Python pip yum Oracle

Added by dcooper on Fri, 24 May 2019 01:02:43 +0300