V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
rocxto
V2EX  ›  Python

请教一个问题,关于 virtualenv

  •  
  •   rocxto · 2014-06-22 10:46:09 +08:00 · 2995 次点击
    这是一个创建于 3598 天前的主题,其中的信息可能已经有所发展或是发生改变。
    在服务上部署的时候,怎么自动激活虚拟环境(网上所有的教程好像都没有这一步)?有经验的同学解答下,谢谢~
    7 条回复    2014-06-22 11:18:43 +08:00
    sfdye
        1
    sfdye  
       2014-06-22 10:52:19 +08:00
    gunicorn配置文件里面设置,或者用fabric


    参考我的这边[博客](http://sfdye.com/articles/django-best-practice-and-deployment-with-nginx-gunicorn-and-supervisor/)吧
    likang
        2
    likang  
       2014-06-22 10:53:46 +08:00
    直接用虚拟环境中的 python 执行你的 py 代码

    如: /path/to/your/env/bin/python foo.py
    awanabe
        3
    awanabe  
       2014-06-22 11:05:09 +08:00   ❤️ 1
    bash执行第一步 source 一下 指定 virtualenv中的 activate 文件.
    具体就是 source virtualenv/xxxproject/bin/activate 就可以.
    awanabe
        4
    awanabe  
       2014-06-22 11:07:26 +08:00
    如果想要 当前服务器的python环境都使用这一个虚拟环境, 就直接在个人的bashrc中 加上source这一段. 然后登陆默认就是这个环境, 执行脚本也是当前虚拟环境. 就不需要每次都source一下
    rocxto
        5
    rocxto  
    OP
       2014-06-22 11:13:55 +08:00
    @sfdye @likang 谢谢
    rocxto
        6
    rocxto  
    OP
       2014-06-22 11:18:29 +08:00
    @awanabe 谢谢
    rocxto
        7
    rocxto  
    OP
       2014-06-22 11:18:43 +08:00
    懂了,结贴:)
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1118 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 18:30 · PVG 02:30 · LAX 11:30 · JFK 14:30
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.