区分 virturalenvwrapper 的 mkvirtualenv 和 mkproject [英] differentiate mkvirtualenv and mkproject for virturalenvwrapper

查看:16
本文介绍了区分 virturalenvwrapper 的 mkvirtualenv 和 mkproject的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我说的是 Doug Hellman 的 virtualenvwrapper.好吧,按照他的说法,一旦我们安装了 virtualenvwrapper,我们应该按照 这里

I am talking about Doug Hellman's virtualenvwrapper. Well, as per him, once we install virtualenvwrapper, we should edit the .bashrc file as explained here

我们所做的是添加以下三行代码:

what we do is we add the following three lines of code:

export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Devel
source /usr/local/bin/virtualenvwrapper.sh

其中 .virtualenv 是放置 venv 的目录.Devel 是代码所在的目录.

where .virtualenv is the directory where the venvs would be placed. Devel is the directory where the code will reside.

观察 1:当我执行 mkvirtualenv proj1 时,会在 .virtualenv 中创建一个名为 proj1 的目录,但不在 Devel 中.

Observation 1: when i do mkvirtualenv proj1 what happens is a directory called proj1 is created inside .virtualenv but NOT inside Devel.

观察 2:当我执行 mkproject proj1 时,会在 .virtualenv 和 Devel 中创建一个目录.

Observation 2: When i do mkproject proj1, a directory inside .virtualenv as well as inside Devel is created.

现在问题:

  1. 请解释观察 1.

如果两个项目具有相同的要求并且我想使用单个 env 并且不想从创建另一个 virtualenv 开始并重新安装已安装的相同内容,该怎么办.我该怎么做?

What if two project have same requirements and i want to use a single env and would not want to start with creating another virtualenv and re install the same thing that is installed. How do i do this?

推荐答案

  1. 这是预期的行为.命令 mkvirtualenv 创建了一个虚拟环境,但它不会为您创建一个项目.有些人使用 Django 进行 Web 开发,其他人使用 Python 进行科学编程,因此 mkvirtualenv 为您设置一些东西太宽泛了.如果您要开始一个新项目,您可以简单地自己创建一个目录.

  1. This is expected behaviour. The command mkvirtualenv creates a virtual environment but it does not create a project for you. Some people do web development with Django, others do scientific programming in Python so it would be too broad for mkvirtualenv to setup something for you. You can simply create a directory yourself if you're starting a new project.

如果两个项目位于不同的目录中,您可以激活虚拟环境,然后导航到任一项目目录进行处理.然后,您还可以在该虚拟环境中执行每个项目的代码.这样您就无需在新的虚拟环境中重新安装要求.

If both projects are in different directories, you can activate the virtual environment and then navigate to either project directory to work on that. You can then also execute the code of each project while you're in that virtual environment. This way you don't need to reinstall the requirements again in a new virtual environment.

这篇关于区分 virturalenvwrapper 的 mkvirtualenv 和 mkproject的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆