从脚本获取virtualenv的bin文件夹路径 [英] Get virtualenv's bin folder path from script

查看:141
本文介绍了从脚本获取virtualenv的bin文件夹路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用具有django项目的virtualenvwrapper,该项目具有自动写入一些配置文件的管理任务,因此用户只需要

I'm using virtualenvwrapper with a django project that has a management task that automatically writes some config files, so the user just has to

./manage.py generate_configuration > much_nice.conf

然后将文件移动到其他位置。生成的配置文件之一是启动芹菜工作者的超级用户任务。我得到的问题是,我不知道如何在virtualenv的bin文件夹中输出芹菜可执行文件的路径。本质上,我想输出命令

And then move the file elsewhere. One of the generated config files is a task for supervisord that launches a celery worker. The problem I'm getting is that I don't know how to output the path of the celery executable that is within the bin folder of the virtualenv. Essentially, I'd like to have the output of the command

which celery

一个选项是使用 sys.executable ,获取文件夹(这似乎是 bin 文件夹中的virtualenv),但是它是...但我不确定。

One option is using sys.executable, get the folder (which seems to be the bin folder of the virtualenv) and that's it... but I'm not sure.

不是virtualenv有获取路径本身的任何种类的方法?

Doesn't virtualenv have any kind of method to get the path itself?

推荐答案

虚拟环境变量的路径在环境变量VIRTUAL_ENV

The path to the virtual env is in the environment variable VIRTUAL_ENV

echo $VIRTUAL_ENV

这篇关于从脚本获取virtualenv的bin文件夹路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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