问题描述
我正在使用virtualenv
对我的Python环境进行沙箱测试,使用pip
安装/卸载软件包,并使用yolk
列出软件包.
I'm using virtualenv
for sandboxing my Python environment, pip
to install/uninstall packages and yolk
to list the packages.
我可以使用pip install <package name> -e=<environment name>
将软件包安装到我的虚拟环境中,我想我不需要在我的虚拟环境中包含pip
.我说得对吗?
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?
如果我需要列出虚拟环境中所有已安装的软件包,可以使用yolk -l
列出吗?我知道可以通过将yolk
安装在环境中来做到这一点,但是也可以通过将yolk
保持在环境之外(即全局Python安装)来实现.
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.
谢谢.
推荐答案
这是您的工作流程:
- 将virtualenv和pip添加到您的全局环境中.
- 创建virtualenvs
- 在virtualenv内添加新软件包
我建议您研究 virtualenvwrapper .它使virtualenvs的维护更加容易.
I recommend you look into virtualenvwrapper. It makes the maintenance of virtualenvs way easier.
- 在您的全局环境中下载并安装virtualenvwrapper
- 创建目录〜/.virtualenvs
-
使用以下语句修改〜/.bashrc:
- Download and install virtualenvwrapper in your global environment
- Create directory ~/.virtualenvs
Modify your ~/.bashrc with these statements:
导出WORKON_HOME = $ HOME/.virtualenvs导出VIRTUALENVWRAPPER_VIRTUALENV_ARGS ='-no-site-packages --python = python2.6'
源/usr/local/bin/virtualenvwrapper.sh
export WORKON_HOME=$HOME/.virtualenvsexport VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages --python=python2.6'
source /usr/local/bin/virtualenvwrapper.sh
然后,您可以轻松地在virtualenv之间创建,删除,修改和更改.
Then you can create, delete, modify, and change between virtualenvs easily.
所以,对于您的问题:
-
我应该在我的virtualenv中放入
pip
吗?
我应该使用yolk
列出软件包吗?
Should I use yolk
to list the packages?
这篇关于将Pip和Yolk放在虚拟环境内部还是外部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!