zoukankan      html  css  js  c++  java
  • python 环境安装

    前言:

    python3应该是python的趋势所在,当然目前争议也比较大,这篇随笔的主要目的是记录在linux64下搭建python3环境的过程

    以及碰到的问题和解决过程。

      另外,如果本机安装了python2,尽量不要管他,使用python3运行python脚本就好,因为可能有程序依赖目前的python2环境,

    比如yum!!!!!

    不要动现有的python2环境!

    不要动现有的python2环境!

    不要动现有的python2环境!

    重要的使用说三遍!

    一、安装python3.6

    下载python3.6安装包:

    wget --no-check-certificate https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz

    解压到当前目录:

    tar -zxvf Python-3.6.0.tgz

    cd Python-3.6.0

    ./configure --prefix=/usr/local/python3.5 --enable-shared

    make & make install

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

    此时运行python3命令的话会报错,缺少.so文件,我们需要进行如下操作:

    cp -R /usr/local/python3.5/lib/* /usr/lib64/

    ok!此时python3的基础环境已经安装完成!

    二、安装pip以及setuptools

    1、安装pip前需要前置安装setuptools(基础包)

    wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-19.6.tar.gz#md5=c607dd118eae682c44ed146367a17e26

    tar -zxvf setuptools-19.6.tar.gz

    cd setuptools-19.6

    python3 setup.py build

    python3 setup.py install

    报错:RuntimeError: Compression requires the (missing) zlib module

    我们需要在linux中安装zlib-devel包,进行支持。

    yum install zlib-devel

    需要对python3.6进行重新编译安装。

    cd python3.6

    make & make install

    又是漫长的编译安装过程。

    重新安装setuptools

    python3 setup.py build

    python3 setup.py install

    2、安装pip(管理包)

    wget --no-check-certificate https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz#md5=3a73c4188f8dbad6a1e6f6d44d117eeb

    tar -zxvf pip-8.0.2.tar.gz

    cd pip-8.0.2

    python3 setup.py build

    python3 setup.py install

    如果没有意外的话,pip安装完成。

    3.安装virtualenv(虚拟环境)

    pip install virtualenv

    报错:pip is configured with locations that require TLS/SSL, however the ssl module in python is not available.
    Collecting xxx
    Could not fetch URL https://pypi.python.org/simple/xxxx/: There was a problem confirming the ssl certificate: Can’t connect to HTTPS URL because the SSL module is not available. - skipping
    Could not find a version that satisfies the requirement xxx (from versions: )
    No matching distribution found for xxx


    3.1.查看openssl安装包,发现缺少openssl-devel包
    [root@Leen ~]# rpm -aq|grep openssl
    openssl-0.9.8e-20.el5
    openssl-0.9.8e-20.el5

    3.2.yum安装openssl-devel
    [root@Leen ~]# yum install openssl-devel -y

    继续重新编译安装python3.6

    ok,完成安装

  • 相关阅读:
    gulp备忘
    好文收藏
    妙味H5交互篇备忘
    [CSS3备忘] transform animation 等
    css选择器总结
    flexbox备忘
    函数
    继承2
    在 Swift 中实现单例方法
    浅谈 Swift 中的 Optionals
  • 原文地址:https://www.cnblogs.com/Xingtxx/p/11745688.html
Copyright © 2011-2022 走看看