python3安装日记

1.在官网下载python3.7.4的压缩包https://www.python.org/downloads/source/
python3安装日记_第1张图片
#已下好sz-hd-03:/usr/local/share/Python-3.7.4.tar.xz
下载到/usr/local/share/路径下
sudo tar -xvf pxxx
sudo mv Python-3.7.4 python3

sudo yum install -y libffi-devel readline-devel
cd python目录

添加配置:sudo ./configure --prefix=/usr/local/share/python3(存放pyton3的文件夹)

开始编译

sudo make
sudo make install
sudo ln -s /usr/local/share/python3/bin/python3.7 /usr/bin/python3
sudo ln -s /usr/local/share/python3/bin/pip3.7 /usr/bin/pip3

报错configure: error: no acceptable C compiler found in $PATH

sudo yum install -y gcc

报错configure: error: C compiler cannot create executables

gcc版本问题
sudo yum -y install centos-release-scl
sudo yum -y install devtoolset-6-gcc
sudo scl enable devtoolset-6 bash

报错 No module named ‘_ctypes’

sudo yum install libffi-devel -y

报错./Modules/_ssl.c:57:25: fatal error: openssl/rsa.h

修改./Modules/Setup文件(将如下四行的注释去掉):

# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:
SSL=/usr/local/ssl
_ssl _ssl.c \
    -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
    -L$(SSL)/lib -lssl -lcrypto

sudo yum install openssl-devel -y

后续操作记录

sudo pip3 install pandas
sudo yum install xz-devel -y
sudo yum install python-backports-lzma -y
sudo pip3 install backports.lzma
sudo cp /usr/local/share/python3/lib/python3.7/lib-dynload/_bz2.cpython-37m-x86_64-linux-gnu.so

sudo vim /usr/local/share/python3/lib/python3.7/lzma.py
第27try:
    from _lzma import *
    from _lzma import _encode_filter_properties, _decode_filter_properties
except ImportError:
    from backports.lzma import *
    from backports.lzma import _encode_filter_properties, _decode_filter_properties
进行替换

你可能感兴趣的:(python)