将全局软件包包含到使用--no-site-packages创建的virtualenv中 [英] Including global package into a virtualenv that has been created with --no-site-packages

查看:95
本文介绍了将全局软件包包含到使用--no-site-packages创建的virtualenv中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通常更喜欢使用--no-site-packages选项创建virtualenvs,以实现更多隔离,并且还因为默认的python全局软件包包含很多软件包,通常通常不需要它们. 但是,我仍然希望在全局范围内保留一些选择的软件包,例如PIL或psycopg2.是否有一个很好的方法可以将它们包含到virtualenv中,也可以轻松地将其自动化?

I'd usually prefer to create virtualenvs with --no-site-packages option for more isolation, and also because default python global packages includes quite a lot of packages, and usually most of them are not needed. However I'd still want to keep a few select packages in global, like PIL or psycopg2. Is there a good way to include them into the virtualenv, that can also be automated easily?

推荐答案

如果您使用的是 virtualenvwrapper ,您也许可以使用 postmkvirtualenv 脚本在新的virtualenv sitepackages目录中自动创建符号链接.

If you're using virtualenvwrapper and you might be able to use the postmkvirtualenv script to automatically create symlinks in the new virtualenv sitepackages directory.

#!/bin/sh
cdsitepackages
ln -s /path/to/system/site-packages/package-name
cdvirtualenv

这篇关于将全局软件包包含到使用--no-site-packages创建的virtualenv中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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