• python3环境搭建(CentOS7.2)



    安装python3(自动安装pip3):
    yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel
    #不安装依赖可能安装完成后没有pip3 软件
    tar xf Python-3.5.2.tgz
    ./configure --prefix=/usr/local/python3
    make
    make install
    ln -sv /usr/local/python3/bin/pip3 /usr/local/bin/
    ln -sv /usr/local/python3/bin/python3 /usr/local/bin/

    [root@xiaofan72 ~]# python
    python python2.7 python3.5 python3.5m python3-config
    python2 python3 python3.5-config python3.5m-config


    django安装:

    pip3 install django==1.9.7

    >>> import sys
    >>> sys.path
    ['', '/usr/local/lib/python35.zip', '/usr/local/lib/python3.5', '/usr/local/lib/python3.5/plat-linux', '/usr/local/lib/python3.5/lib-dynload', '/usr/local/lib/python3.5/site-packages']

    把django拷贝到sys.path中:
    cp -a /usr/local/python3/lib/python3.5/site-packages/django/ /usr/local/lib/python3.5/

    >>> import django
    >>> django.VERSION
    (1, 9, 7, 'final', 0)

    -------------------------------------------------------------------


    源码安装pip:

    https://pypi.python.org/pypi/pip/8.1.2
    tar xf pip-8.1.2.tar.gz
    cd pip-8.1.2


    #如果安装python2的pip则用python2
    python3 setup.py install
    如果报错:
    Traceback (most recent call last):
    File "setup.py", line 6, in <module>
    from setuptools import setup, find_packages
    ImportError: No module named 'setuptools'


    需要安装setuptools(python的一个增强工具,更方便发布和创建pyton包)
    tar xf setuptools-25.2.0.tar.gz
    cd setuptools-25.2.0/
    python3 setup.py install


    再次安装pip3:
    python3 setup.py install

  • 相关阅读:
    【剑指Offer】面试题14- I. 剪绳子
    【剑指Offer】面试题56
    【LeetCode】202. 快乐数
    【LeetCode】1095. 山脉数组中查找目标值
    【LeetCode】260. 只出现一次的数字 III
    【剑指Offer】面试题56
    【LeetCode】33. 搜索旋转排序数组
    【LeetCode】23. 合并K个排序链表
    【LeetCode】46. 全排列
    mysql可视化工具下载地址2017.6.27
  • 原文地址:https://www.cnblogs.com/fanxuanhui-linux/p/5827430.html
Copyright © 2020-2023  润新知