Fork me on GitHub

【Python】01.环境搭建

一、下载安装

        1)windows Python下载地址 https://www.python.org/downloads/release/python-373/

        2)自定义下一步安装即可

二、安装插件

        1)安装pip

          下载 https://pypi.org/project/pip/#files

          image

         解压后进入文件夹 执行python setup.py instatll

         cmd中执行pip是否执行成功

        2) 安装mysql

      pip install PyMySQL
      git clone https://github.com/PyMySQL/PyMySQL
      cd PyMySQL/
      python setup.py install
     3)安装requests
      pip install requests

三、Linus下安装Python3

        1)安装依赖

           yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel

           yum –y install sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

           yum install gcc libffi-devel –y

        2)下载并解压到目录/usr/local

            wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tar.xz

            tar -xvJf Python-3.7.1.tar.xz && cd Python-3.7.1

        3)编译安装

            ./configure --prefix=/usr/local/python3 --with-ssl

            make && make install

        4)创建软连接

            ln -s /usr/local/python3/bin/python3 /usr/bin/python3

            ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

        5)查看版本

           python3 –V

           pip3 –V

        6)查看是否ssl导入成功

         image

        7)如果不能成功引入ssl需要升级openssl

#下载
wget https://www.openssl.org/source/openssl-1.1.1a.tar.gz

#解压安装
tar -zxvf openssl-1.1.1a.tar.gz
cd openssl-1.1.1a

#配置编译安装
./config --prefix=/usr/local/openssl no-zlib
 make
make install

#备份原配置
mv /usr/bin/openssl /usr/bin/openssl.bak
mv /usr/include/openssl/ /usr/include/openssl.bak

#新版配置
ln -s /usr/local/openssl/include/openssl /usr/include/openssl
ln -s /usr/local/openssl/lib/libssl.so.1.1 /usr/local/lib64/libssl.so
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl

#修改系统配置
echo "/usr/local/openssl/lib" >> /etc/ld.so.conf

#使配置生效
ldconfig –v

#查看openssl版本
openssl version

重新安装Python

四、Linus卸载Python3

     1)卸载Python3

         rpm -qa|grep python3|xargs rpm -ev --allmatches --nodeps

     2)删除残余文件

        whereis python3 |xargs rm -frv

     3)whereis python 查看现有安装的python

posted @ 2020-05-08 17:08  mankeu  阅读(198)  评论(0编辑  收藏  举报