如何将新的默认软件包添加到virtualenv? [英] How to add new default packages to virtualenv?

查看:78
本文介绍了如何将新的默认软件包添加到virtualenv?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我创建一个virtualenv时,它会安装setuptools和pip.可以在此列表中添加新软件包吗?

When I create a virtualenv, it installs setuptools and pip. Is it possible to add new packages to this list?

用例示例:

  • 按照此解决方案在virtualenv中使用ipython(来自此问题),需要在每个virtualenv中安装ipython(除非我允许系统-网站软件包).
  • 或者,如果我只做Flask/pygame/framework开发,我希望在每个virtualenv中使用它.
  • Following this solution to use ipython in virtualenv (from this question) requires installing ipython in every virtualenv (unless I allow system-site-packages).
  • Or if I'm doing a only flask/pygame/framework development, I'd want it in every virtualenv.

推荐答案

我采用了与选择正确答案不同的方法.

I took a different approach from what is chosen as the correct answer.

我选择了我的目录,例如~/.virtualenv/deps,并在其中安装了软件包

I chose I directory, like ~/.virtualenv/deps and installed packages in there by doing

pip install -U --target ~/.virtualenv/deps ...

接下来在~/.virtualenv/postmkvirtualenv中,我输入了以下内容:

Next in ~/.virtualenv/postmkvirtualenv I put the following:

# find directory
SITEDIR=$(virtualenvwrapper_get_site_packages_dir)
PYVER=$(virtualenvwrapper_get_python_version)

# create new .pth file with our path depending of python version
if [[ $PYVER == 3* ]];
then
    echo "$HOME/.virtualenvs/deps3/" > "$SITEDIR/extra.pth";
else
    echo "$HOME/.virtualenvs/deps/" > "$SITEDIR/extra.pth";
fi

基本上说出相同意思的帖子.

这篇关于如何将新的默认软件包添加到virtualenv?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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