centos 默认安装的python是2.6版本的

使用virtualenv 环境管理工具建立python虚拟环境的时候会遇到一些错误,DEPRECATION: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of pip will drop support for Python 2.6

好像是python2.6 官方不在支持 virtualenv

1.升级python版本 到2.7

2.删除删除掉以前的setuptools,pip(/usr/bin下也要删干净)

pip uninstall setuptools
  pip uninstall pip

重新安装

下载pip

wget "https://pypi.python.org/packages/source/p/pip/pip-1.5.4.tar.gz#md5=834b2904f92d46aaa333267fb1c922bb" --no-check-certificate

解压

tar -zxvf pip-1.5.4.tar.gz

cd pip-1.5.4

python setup.py install

(此时报错,找不到setuptools.)

首先安装setuptools

下载setuptools安装脚本

wget –q http://peak.telecommunity.com/dist/ez_setup.py

python ez_setup.py 执行

再次执行 python setup.py install

OK

最后使用  mkvirtualenv --help命令查看,可以使用virtualenv了

[root@localhost ~]# mkvirtualenv --help
Usage: mkvirtualenv [-a project_path] [-i package] [-r requirements_file] [virtualenv options] env_name

-a project_path

Provide a full path to a project directory to associate with
the new environment.

-i package

Install a package after the environment is created.
This option may be repeated.

-r requirements_file

Provide a pip requirements file to install a base set of packages
into the new environment.

virtualenv help:

Usage: virtualenv [OPTIONS] DEST_DIR

Options:
--version show program's version number and exit
-h, --help show this help message and exit
-v, --verbose Increase verbosity.
-q, --quiet Decrease verbosity.
-p PYTHON_EXE, --python=PYTHON_EXE
The Python interpreter to use, e.g.,
--python=python2.5 will use the python2.5 interpreter
to create the new environment. The default is the
interpreter that virtualenv was installed with
(/usr/bin/python)
--clear Clear out the non-root install and start from scratch.
--no-site-packages DEPRECATED. Retained only for backward compatibility.
Not having access to global site-packages is now the
default behavior.
--system-site-packages
Give the virtual environment access to the global
site-packages.
--always-copy Always copy files rather than symlinking.
--unzip-setuptools Unzip Setuptools when installing it.
--relocatable Make an EXISTING virtualenv environment relocatable.
This fixes up scripts and makes all .pth files
relative.
--no-setuptools Do not install setuptools in the new virtualenv.
--no-pip Do not install pip in the new virtualenv.
--no-wheel Do not install wheel in the new virtualenv.
--extra-search-dir=DIR
Directory to look for setuptools/pip distributions in.
This option can be used multiple times.
--download Download preinstalled packages from PyPI.
--no-download, --never-download
Do not download preinstalled packages from PyPI.
--prompt=PROMPT Provides an alternative prompt prefix for this
environment.
--setuptools DEPRECATED. Retained only for backward compatibility.
This option has no effect.
--distribute DEPRECATED. Retained only for backward compatibility.
This option has no effect.

但是  读入环境还是报错

[root@localhost ~]# source /root/.bashrc
/usr/local/bin/python: No module named virtualenvwrapper
virtualenvwrapper.sh: There was a problem running the initialization hooks.

If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenvwrapper has been installed for
VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python and that PATH is
set properly.

查了下好像是virtualenvwrapper 版本低了的原因 升级了virtualenvwrapper

[root@localhost ~]# /usr/local/bin/pip install virtualenvwrapper --upgrade

就OK 了

建立虚拟运行环境

[root@localhost ~]# mkvirtualenv newenv

[root@localhost ~]# mkvirtualenv newenv
New python executable in /root/.virtualenvs/newenv/bin/python
Installing setuptools, pip, wheel...done.
virtualenvwrapper.user_scripts creating /root/.virtualenvs/newenv/bin/predeactivate
virtualenvwrapper.user_scripts creating /root/.virtualenvs/newenv/bin/postdeactivate
virtualenvwrapper.user_scripts creating /root/.virtualenvs/newenv/bin/preactivate
virtualenvwrapper.user_scripts creating /root/.virtualenvs/newenv/bin/postactivate
virtualenvwrapper.user_scripts creating /root/.virtualenvs/newenv/bin/get_env_details

从这里可以看出 新建的虚拟运行环境目录在  /root/.virtualenvs目录下, 虚拟运行环境目录是根据环境变量WORKON_HOME设定决定的

这是我的环境变量:

export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/bin/virtualenv
source /usr/bin/virtualenvwrapper.sh

此时进入虚拟运行环境的命令变成了 workon

[root@localhost .virtualenvs]# workon newenv
(newenv) [root@localhost .virtualenvs]#

也可以直接 cd  /root/.virtualenvs

退出环境 deactivate

(newenv) [root@localhost .virtualenvs]# deactivate
[root@localhost .virtualenvs]#

python 使用virtualenvrapper虚拟环境管理工具的更多相关文章

  1. python开发之虚拟环境管理:virtualenv、virtualenvwrapper、pycharm

    1 引言 进行Python开发时,多个项目可能使用到不同的依赖,例如A项目需要1.8版本的Django,而B项目需要2.0版本的Django,这时候如果没有使用虚拟环境,就需要来回卸载和安装Djang ...

  2. nave node 的虚拟环境管理工具

    nave 是类似python venv 的node 虚拟环境管理工具 安装 npm install -g nave 简单使用 帮助命令 Usage: nave <cmd> Commands ...

  3. pythonWeb框架创建app模块以及虚拟环境管理工具

    在进行项目搭建的时候,如果有多个功能模块,以及多个网页地址时,为了系统的可维护性,以及易读性,我们大多数情况下选择模块化开发 所以我们就要使用app指令来创建不同的功能模块 首先项目框架如下: 接下来 ...

  4. python的虚拟环境管理工具venv使用方法介绍及与nodejs的包管理方式对比

    一.nodejs 包管理方式 我们知道, nodejs的包管理工具npm可以安装项目所需要的包,安装方法及区别如下: npm i module_name -g 全局安装 npm i module_na ...

  5. Python虚拟环境管理工具virtualenvwrapper安装及配置

      1. 安装virtualenv 使用pip install virtualenv安装virtualenv虚拟环境工具 2. 安装virtualenvwrapper a) Linux环境,直接使用p ...

  6. 虚拟环境管理工具virtualenvwrapper-win初试

    virtualenv 用于建立虚拟目录,但是每次进入指定虚拟都必须activate, 而且如果一个环境很久没用了,不记得环境所在目录,就会遗忘该环境,virtualenvwrapper 正是解决以上问 ...

  7. Miniconda虚拟环境管理工具命令方法

    创建制定Python版本的虚拟环境 conda create --name 虚拟环境名称 Python=3.7.3(版本号) 进入指定虚拟环境 conda activate 虚拟环境名称 退出虚拟环境 ...

  8. anaconda虚拟环境管理,从此Python版本不用愁

    1 引言 在前几篇博文中介绍过virtualenv.virtualenvwrapper等几个虚拟环境管理工具,本篇要介绍的anaconda也有很强大的虚拟环境管理功能,甚至相比virtualenv.v ...

  9. Anaconda 包管理工具 conda 进行虚拟环境管理入门

    在基于 python 进行数据分析.机器学习等领域的实践和学习时,由于代码的更迭和更新,运行他人实现的代码或尝试安装新的工具库时往往需要指定特定版本的其他工具库,以满足特定环境的构建条件.而将同一工具 ...

随机推荐

  1. BaseHttpListActivity,几行代码搞定Android Http列表请求、加载和缓存

    Android开发中,向服务器请求一个列表并显示是非常常见的需求,但实现起来比较麻烦,代码繁杂. 随着应用的更新迭代,这种需求越来越多,我渐渐发现了实现这种需求的代码的共同点. 于是我将Activit ...

  2. Sql server 2008 中varbinary查询

    sqlserver2008中遇到一个坑爹的问题,使用以下语句添加的数据 insert into testtable ( username, password, productcode ) select ...

  3. C# UdpClient使用Receive和BeginReceive接收消息时的不同写法

    使用Receive(同步阻塞方式), 注意使用同步方法时,需要使用线程来开始方法,不然会使UI界面卡死 IPEndPoint RemoteIpEndPoint = ); UdpClient udpCl ...

  4. Uploadify使用随笔

    最近项目使用了Uploadify一个上传插件,感觉的挺好用的. 上传控件: 引用JS <script src='<% =ResolveUrl("~/JS/Uploadify/jq ...

  5. Oracle开窗函数 over()(转)

    copy文链接:http://blog.csdn.net/yjjm1990/article/details/7524167#,http://www.2cto.com/database/201402/2 ...

  6. windows10(x64)+Qt+opencv配置及测试

    本电脑系统:Windows10 64位 要下载的文件: 1.Qt 5.6.0 for Windows 32-bit,下载地址:(可以复制链接地址,用迅雷下载,速度快) http://download. ...

  7. linux下内存泄露检测工具Valgrind介绍

    目前在linux开发一个分析实时路况的应用程序,在联合测试中发现程序存在内存泄露的情况. 这下着急了,马上就要上线了,还好发现了一款Valgrind工具,完美的解决了内存泄露的问题. 推荐大家可以使用 ...

  8. unix basic command

    1. get start Command Example Description ls ls ls -a ls -l 输出目录文件 输出文件包括隐藏文件 输出文件详细信息 pwd pwd show p ...

  9. iOS学习之MVC模式

    Modal 模型对象: 模型对象封装了应用程序的数据,并定义操控和处理该数据的逻辑和运算.例如,模型对象可能是表示商品数据 list.用户在视图层中所进行的创建或修改数据的操作,通过控制器对象传达出去 ...

  10. Hadoop原理介绍

    Hadoop核心之HDFS 架构设计   老嗨 2015-09-18 16:55:00 浏览225 评论0 摘要: 概述:HDFS即Hadoop Distributed File System分布式文 ...