zoukankan      html  css  js  c++  java
  • linux系统 python升级创建虚拟环境

    Python3.3以上的版本通过venv模块原生支持虚拟环境,可以代替之前的virtualenv。

    该venv模块提供了创建轻量级“虚拟环境”,提供与系统Python的隔离支持。每一个虚拟环境都有其自己的Python二进制(允许有不同的Python版本创作环境),

    并且可以拥有自己独立的一套Python包。

    python3.4以上包含pip命令

    环境:Linux  centos 7.3    python2.7.5  

    源码安装python3.6.6  放在目录 /usr/local/python3.6.6下面

    目前是两个python共存

    下面开始创建虚拟环境

    [root@centos7 ~]# mkdir test   //新建一个目录
    [root@centos7 ~]# cd test
    [root@centos7 test]# python    //目前的python版本
    python     python2    python2.7  python3.6  
    [root@centos7 test]# /usr/local/python3.6.6/bin/python3 -m venv .  //创建虚拟环境
    [root@centos7 test]# find /usr/local/python3.6.6/ -name activate   //这个省略
    /usr/local/python3.6.6/Python-3.6.6/Lib/venv/scripts/common/activate
    /usr/local/python3.6.6/lib/python3.6/venv/scripts/common/activate
    [root@centos7 test]# ls
    bin  include  lib  lib64  pyvenv.cfg
    [root@centos7 test]# more pyvenv.cfg  //查看里面多个pyvenv.cfg文件
    home = /usr/local/python3.6.6/bin
    include-system-site-packages = false
    version = 3.6.6
    [root@centos7 test]# source bin/activate    //这个目录相当于一个相对目录,下面并没有此文件
    (test) [root@centos7 test]# python          //开始测试
    Python 3.6.6 (default, Sep  1 2018, 17:07:25) 
    [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> print(123,end='	')                                                                       123     >>> 
    >>> exit()
    (test) [root@centos7 test]# deactive    //退出
    bash: deactive: command not found...
    (test) [root@centos7 test]# deactivate
    [root@centos7 test]#
  • 相关阅读:
    PHP 对Memcache的使用实例
    PHP Memcache 扩展安装
    Effective STL 读书笔记
    windows下安装和使用scrapy
    使用insert ignore来避免向数据库重复插入数据
    2017年末
    归并排序
    二叉树的中序遍历
    正则表达式
    tinymq学习小结
  • 原文地址:https://www.cnblogs.com/mmyy-blog/p/9597324.html
Copyright © 2011-2022 走看看