通过os.system()激活virtualenv [英] Activate virtualenv via os.system()
问题描述
os.system('virtualenv%s --no-site-packages'%project_name)
os.system('source%s / bin / activate'%project_name)
os.system('easy_install pip $)
运行时出现错误:
$ startproject + -s false sample
示例中的新的python可执行文件/ bin / python
安装setuptools ............完成。
/ testing
搜索pip
最佳匹配:pip 0.4
处理pip-0.4-py2.6.egg
pip 0.4已经是easy- install.pth
将脚本安装到/ usr / local / bin
错误:/ usr / local / bin / pip:Permission denied
显然,源
行没有运行,但为什么?这是一个并发/线程问题,还是使用virtualenv更深层次的问题?
谢谢!
每个 os.system
调用创建一个新进程。您需要确保激活
和 easy_install
在相同的 os中运行.system
或 subprocess
call。
I'm writing a Python-based shell script to boilerplate a Django app with virtualenv, pip, and fabric. Should be straightforward enough, but it appears that I'm not able to activate and run commands in the virtualenv through the shell script.
os.system('virtualenv %s --no-site-packages' % project_name)
os.system('source %s/bin/activate' % project_name)
os.system('easy_install pip')
When running, this errors out:
$ startproject+ -s false sample
New python executable in sample/bin/python
Installing setuptools............done.
/testing
Searching for pip
Best match: pip 0.4
Processing pip-0.4-py2.6.egg
pip 0.4 is already the active version in easy-install.pth
Installing pip script to /usr/local/bin
error: /usr/local/bin/pip: Permission denied
Obviously the source
line isn't being run, but why? Is it a concurrency/threading issue, or something deeper with virtualenv?
Thanks!
Each os.system
call creates a new process. You'll need to ensure that the activate
and the easy_install
are run in the same os.system
or subprocess
call.
这篇关于通过os.system()激活virtualenv的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!