Can I automatically change my PYTHONPATH when activating/deactivating a virtualenv?

后端 未结 2 1898
一个人的身影
一个人的身影 2021-02-02 17:19

I would like to have a different PYTHONPATH from my usual in a particular virtualenv. How do I set this up automatically? I realize that it\'s possible to hack the bin/act

2条回答
  •  名媛妹妹
    2021-02-02 17:52

    This django-users post is probably going to help you a lot. It suggests using virtualenvwrapper to wrap virtualenv, to use the add2virtualenv command. Using this, when the environment is active, you can just call:

    add2virtualenv directory1 directory2 ...
    

    to add the directories to your pythonpath for the current environment.

    It handles autonomously the PATH changes on environment switches. No black magic required. Et voila!

提交回复
热议问题