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. sql 2008 修改链接服务器 Rpc &Rpc Out

    From: http://blog.csdn.net/gnolhh168/article/details/41725873 USE [master] GO EXEC master.dbo.sp_ser ...

  2. java基础之 重排序

    重排序通常是编译器或运行时环境为了优化程序性能而采取的对指令进行重新排序执行的一种手段.重排序分为两类:编译期重排序和运行期重排序,分别对应编译时和运行时环境. 在并发程序中,程序员会特别关注不同进程 ...

  3. 例子:Background Transfer Service Sample

    本例演示了如何使用后台传输服务来进行后台文件下载,也就是说及时App已经停止运行,同样可以通过后台代理进行文件的下载操作. 对于后台文件传输一下知识点必须注意: 1. 通过使用 BackgroundT ...

  4. Consistent hashing —— 一致性哈希

    原文地址:http://www.codeproject.com/Articles/56138/Consistent-hashing 基于BSD License What is libconhash l ...

  5. 虚拟机下Linux读取USB设备的问题虚拟机下Linux无法读取USB设备的解决方案

    我们在虚拟机中识别USB设备有三种情况导致Linux系统不能读取到USB设备: 1. .当虚拟机的USB服务没有开启的时候 2. 若虚拟机的USB连接的设置选项没有设置好 3. Widows抢先一步, ...

  6. poj1847 最短路

    //Accepted 188 KB 32 ms //spfa 最短路 //每个intersection到第一个连接点是不要switch的 //到其他的intersection要switch一次 #in ...

  7. php+mysql的微信文章发布平台

    如何在微信上发表丰富图文的文章? 最近在新浪云平台上做了一个php+mysql的微信文章发布平台,丫丫说. 在线编辑文章,扫一扫即可分享到微信,发到朋友圈,非常简单! http://yayashuo. ...

  8. IOS百度地图获取所在的城市名称

    笔者的app要实现定位所在省和城市名称,借此总结巩固一下! @interface VenueListVC : BasePageTableViewVC<BMKLocationServiceDele ...

  9. hdu 2074

    ps:WA了好多次...因为首先是n=1的情况,其次是中心花色和外花色,中心花色也有可能是最外层花色....很无语. 然后就是格式问题咯. 代码 #include "stdio.h" ...

  10. Log4j简介

    Log4J日志配置详解   一.Log4j简介Log4j有三个主要的组件:Loggers(记录器),Appenders (输出源)和Layouts(布局).这里可简单理解为日志类别,日志要输出的地方和 ...