Linux我用 LinuxLinux学习|Gentoo/Arch/FreeBSD

Linux 服务器(CentOS7)安装 Python-3.7.

2020-04-08  本文已影响0人  AptX395

本文已经发布在我的个人网站上啦,欢迎访问


安装 Python-3.7.5

前期准备

编译安装

  1. 进入源码包目录后执行编译安装:

    ./configure --prefix=/usr/local/python37 --enable-optimizations
    make
    make install
    
  2. 建立软链接:

    ln -s /usr/local/python37/bin/python3.7 /usr/bin/python37
    

验证安装

python37 --version

安装 Subversion-1.12.2

前期准备

安装其他依赖

  1. 进入 apr-1.7.0 源码包目录后执行编译:

    ./configure --prefix=/usr/local/apr
    make
    make install
    
  2. 进入 apr-util-1.6.1 源码包目录后执行编译:

    ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
    make
    make install
    
  3. 进入 scons-3.1.0 源码包目录后执行编译:

    注意:编译安装 scons 需要系统环境变量 python 默认调用 Python2

    python setup.py install --prefix=/usr/local/scons
    
  4. 进入 serf-1.3.9 源码包目录后执行编译:

    注意:编译 serf 需要使用上一步中安装的 scons

    /usr/local/scons/bin/scons PREFIX=/usr/local/serf APR=/usr/local/apr APU=/usr/local/apr-util
    /usr/local/scons/bin/scons install
    cp /usr/local/serf/lib/libserf-1.so* /usr/local/lib
    
  5. 进入 sqlite-autoconf-3300100 源码包目录后执行编译:

    ./configure --prefix=/usr/local/sqlite
    make
    make install
    
  6. 进入 utf8proc-2.4.0 源码包目录后执行编译:

    make
    make install
    

编译安装

  1. 进入 subversion-1.12.2 源码包目录后执行编译:

    如果报了 httpd 相关的错误,一定要加上 --enable-apache-whitelist=2.4.6--enable-broken-httpd-auth 这两个参数,其中的 2.4.6httpd 的版本。

    ./configure --prefix=/usr/local/subversion --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-serf=/usr/local/serf --with-sqlite=/usr/local/sqlite --with-zlib --with-lz4 --with-uft8proc --enable-maintainer-mode --enable-mod-activation --enable-apache-whitelist=2.4.6 --enable-broken-httpd-auth
    make
    make install
    
  2. 卸载系统上的旧版本 Subversion

    yum remove subversion
    
  3. 建立软链接:

    ln -s /usr/local/subversion/bin/svn /usr/bin/svn
    

验证安装

svn --version
svn: error while loading shared libraries: libserf-1.so.1: cannot open shared object file: No such file or director
  1. 配置库文件:

    cd /etc/ld.so.conf.d
    vim user-libs.conf
    # 写入 /usr/local/lib 并保存退出
    ldconfig
    
  2. 验证安装:

    svn --version
    

    正常执行,无报错。

安装 PySVN-1.9.10

前期准备

下载并解压 PySVN-1.9.10 的源码包:

wget https://jaist.dl.sourceforge.net/project/pysvn/pysvn/V1.9.10/pysvn-1.9.10.tar.gz
tar -zxvf pysvn-1.9.10.tar.gz

编译安装

  1. 将系统环境变量 python 配置为默认调用 Python-3.7.5

    mv /usr/bin/python /usr/bin/python.bak
    ln -s /usr/local/python37/bin/python3.7 /usr/bin/python
    
  2. 进入 pysvn-1.9.10 源码包目录下的 Source 目录并执行编译:

    python ./setup.py configure --pycxx-dir=../Import/pycxx-7.1.3/ --svn-inc-dir=/usr/local/subversion/include/subversion-1/ --svn-lib-dir=/usr/local/subversion/lib/ --svn-bin-dir=/usr/local/subversion/bin/ --apr-inc-dir=/usr/local/apr/include/apr-1/ --apr-lib-dir=/usr/local/apr/lib/  --apu-inc-dir=/usr/local/apr-util/include/apr-1/
    make
    
  3. 将编译生成的 pysvn 目录下的模块文件复制到 Python-3.7.5site-packages 里面:

    cp -r pysvn /usr/local/python37/lib/python3.7/site-packages/
    

验证安装

python
>>> import pysvn
Traceback (most recent call last):
  File "/data/home/jerrywjdeng/Downloads/pysvn-1.9.10/Source/pysvn/__init__.py", line 112, in <module>
    import pysvn._pysvn_3_7
ImportError: /usr/local/apr-util/lib/libaprutil-1.so.0: undefined symbol: apr_allocator_align

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/data/home/jerrywjdeng/Downloads/pysvn-1.9.10/Source/pysvn/__init__.py", line 122, in <module>
    raise ImportError( 'pysvn was built against newer (svn, apr, etc.) libraries then the ones installed on this system. %s' % str(e) )
ImportError: pysvn was built against newer (svn, apr, etc.) libraries then the ones installed on this system. /usr/local/apr-util/lib/libaprutil-1.so.0: undefined symbol: apr_allocator_align
  1. 分别执行 ldd 查看引用差异:

    ldd /usr/local/python37/lib/python3.7/site-packages/pysvn/_pysvn_3_7.so
    ldd /usr/local/subversion/lib/libsvn_delta-1.so.0
    
  2. 对比发现 apr 文件有差异:

    _pysvn_2_7.so:
        libapr-1.so.0 => lib64/libapr-1.so.0 (0x00007f7eaa42b000)
    libsvn_delta-1.so.0:
        libapr-1.so.0 => /usr/local/apr/lib/libapr-1.so.0 (0x00007f19605ae000)
    
  3. 备份 /usr/lib64/libapr*

    cd /lib64
    mv libapr-1.so.0 libapr-1.so.0.bak
    mv libapr-1.la libapr-1.la.bak
    mv libapr-1.so libapr-1.so.bak
    mv libapr-1.so.0.4.8 libapr-1.so.0.4.8.bak
    
  4. /usr/local/apr/lib/ 下的类文件替换 /lib64/ 下的原 libapr*

    cd /usr/local/apr/lib
    cp libapr-1.la /lib64/
    cp libapr-1.so.0.7.0 /lib64/
    cd /lib64
    ln -s libapr-1.so.0.7.0 libapr-1.so.0
    ln -s libapr-1.so.0.7.0 libapr-1.so
    
  5. 验证安装:

    python
    >>> import pysvn
    >>> client = pysvn.Client()
    

    正常执行,无报错。


上一篇下一篇

猜你喜欢

热点阅读