问题
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:
- Add virtualenv and pip to your global environment.
- Create virtualenvs
- Within a virtualenv, add new packages
I recommend you look into virtualenvwrapper. It makes the maintenance of virtualenvs way easier.
- Download and install virtualenvwrapper in your global environment
- Create directory ~/.virtualenvs
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:
Should I put
pip
inside my virtualenv?No, do not do that.
Should I use
yolk
to list the packages?Not familiar with
yolk
. I just usepip 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