使用 virtualenv 安装某些软件包
所以,我想今年开始使用 virtualenv。 我喜欢 no-site-packages 选项,这很好。 但是我想知道如何将某些软件包安装到每个 virtualenv 中。 例如,假设我想将 django 安装到每个 virtualenv 中...这可能吗?如果可以,如何实现? 扩建能解决这个问题吗?
好吧,它不是 django,更像是 django 应用程序...我不介意在每个 virtualenv 中安装一个版本的 django...我只是想知道是否有一些“no-site-packages”的中间选项
So, I want to start using virtualenv this year. I like the no-site-packages option, that is nice. However I was wondering how to install certain packages into each virtualenv. For example, lets say I want to install django into each virtualenv... is this possible, and if so, how? Does buildout address this?
Well it's not so much django, more like the django applications... I dont mind installing a version of django into each virtualenv... i was just wondering if there was some intermediate option to 'no-site-packages'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我知道您从哪里选择无站点选项。 我想使用 pip freeze 生成需求列表,并且不希望站点包中有太多额外的内容。 我还需要使用多个版本的 django,因为我有尚未升级的遗留项目(一些旧的 svn checkouts (pre1.0)、一些 1.0 和一些新的 svn checkouts)。 在全局站点包中安装 Django 并不是一个真正的选择。
相反,我有一个 django 文件夹,其中包含版本和几个不同的 svn 版本,并且只是符号链接到本地站点包中的适当版本。 为了便于使用,我链接到与环境处于同一级别的本地站点包,然后链接到适当的 django 目录和我需要的任何其他“系统”样式包(通常只是 PIL)。 所以:
现在可以进行以下操作:
I know where you're coming from with the no-sites-option. I want to use pip freeze to generate requirements lists and don't want a lot of extra cruft in site-packages. I also need to use multiple versions of django as I have legacy projects I haven't upgraded (some old svn checkouts (pre1.0), some 1.0, and some new svn checkouts). Installing Django in the global site-packages isn't really an option.
Instead I have a django folder with releases and a couple of different svn versions and just symlink to the appropriate version in the local site-packages. For ease of use I link to the local site-packages at the same level as the environment and then link in the appropriate django directory and any other "system" style packages I need (usually just PIL). So:
Now the following works:
如果你想让django安装在每个virtualenv上,你不妨将它安装在site-packages目录中? 只是一个想法。
If you want django to be installed on EACH virtualenv, you might as well install it in the site-packages directory? Just a thought.
我建议使用
virtualenv
的 引导支持。 这允许您在创建 virtualenv 后执行任意 Python,例如安装新包。I'd suggest using
virtualenv
's bootstrapping support. This allows you to execute arbitrary Python after the virtualenv is created, such as installing new packages.另一种选择(我使用过的一个)是在创建虚拟环境后 Easy_install Django。 这很容易编写脚本。 您付出的代价是等待在每个虚拟环境中安装 Django。
不过,我同意 Toby 的观点:除非有令人信服的理由为什么您必须在每个虚拟环境中拥有单独的 Django 副本,否则您应该考虑将其安装在您的主要 Python 区域中,并允许每个从那里使用它的虚拟环境。
The other option (one I've used) is to easy_install Django after you've created the virtual environment. This is easily scripted. The penalty you pay is waiting for Django installation in each of your virtual environments.
I'm with Toby, though: Unless there's a compelling reason why you have to have a separate copy of Django in each virtual environment, you should just consider installing it in your main Python area, and allowing each virtual environment to use it from there.
我想看看这个项目:
http://www.stereoplex.com/two-voices/fez-djangoskel-django-projects-and-apps-as-eggs
可能是我的答案......
I want to check out this project:
http://www.stereoplex.com/two-voices/fez-djangoskel-django-projects-and-apps-as-eggs
Might be my answer....