pipenv : how to force virtualenv directory?

前端 未结 4 1151
小鲜肉
小鲜肉 2021-01-17 18:34

Actually, pipenv will install the virtualenv with a path like this :

$WORKON_HOME/-

Is it possible to have exac

相关标签:
4条回答
  • 2021-01-17 18:49

    There's an undocumented feature in pipenv: if you create a file named .venv in the project root with a path in it, pipenv will use that instead of an autogenerated path.

    This, however, is more fit for cases when you already have an established set of environments that you wish to reuse. Otherwise, placing environments in arbitrary places is prone to create a mess eventually. pipenv relieves you from this task specifically to keep them all in one predictable place and eliminate accidental collisions from human error.

    0 讨论(0)
  • 2021-01-17 18:53

    In windows, Pycharm user by

    1. make .venv fold in project

    2. Settings->Project->Project interpreter->pipenv Environment

    it works for me

    0 讨论(0)
  • 2021-01-17 18:59

    There is an undocumented feature of pipenv, it could locate virtualenv path from VIRTUAL_ENV environment variable, but you need to create virtualenv manually:

    virtualenv /home/user/myapp_venv
    VIRTUAL_ENV=/home/user/myapp_venv pipenv install
    
    0 讨论(0)
  • 2021-01-17 19:02

    Apart from using a custom location, you can also install the virtualenv in your project's directory. Just add the following line in your .bashrc/.zshrc file:

    export PIPENV_VENV_IN_PROJECT=1
    

    Just wanted to let others know that there is another approach available too.

    Should you keep the virtualenv inside or outside the project's directory is an opinionated question afterall.

    0 讨论(0)
提交回复
热议问题