Place Pip and Yolk inside or outside a virtual environment?

南楼画角 提交于 2019-12-09 23:36:14

问题


I'm using virtualenv for sandboxing my Python environment, pip to install/uninstall packages and yolk to list the packages.

I can install packages to my virtual environment by using pip install <package name> -e=<environment name> and I guess I don't need to have pip inside my virtual environment. Am i correct?

If I need to list out all the installed packages in my virtual environment, can I use yolk -l to do so? I know I can do this by keeping yolk installed inside the environment but is this also possible by keeping yolk outside the environment i.e. the global Python installation.

Thanks.


回答1:


Here is your workflow:

  1. Add virtualenv and pip to your global environment.
  2. Create virtualenvs
  3. Within a virtualenv, add new packages

I recommend you look into virtualenvwrapper. It makes the maintenance of virtualenvs way easier.

  1. Download and install virtualenvwrapper in your global environment
  2. Create directory ~/.virtualenvs
  3. Modify your ~/.bashrc with these statements:

    export WORKON_HOME=$HOME/.virtualenvs export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages --python=python2.6'
    source /usr/local/bin/virtualenvwrapper.sh

Then you can create, delete, modify, and change between virtualenvs easily.

So, for your questions:

  1. Should I put pip inside my virtualenv?

    No, do not do that.

  2. Should I use yolk to list the packages?

    Not familiar with yolk. I just use pip freeze and then I get a requirements file that lists all the packages for recreating my environment.



来源:https://stackoverflow.com/questions/7130516/place-pip-and-yolk-inside-or-outside-a-virtual-environment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!