Install a Python package into a different directory using pip?

后端 未结 16 2615
借酒劲吻你
借酒劲吻你 2020-11-22 05:55

I know the obvious answer is to use virtualenv and virtualenvwrapper, but for various reasons I can\'t/don\'t want to do that.

So how do I modify the command

16条回答
  •  一整个雨季
    2020-11-22 06:23

    The --target switch is the thing you're looking for:

    pip install --target=d:\somewhere\other\than\the\default package_name
    

    But you still need to add d:\somewhere\other\than\the\default to PYTHONPATH to actually use them from that location.

    -t, --target


    Install packages into . By default this will not replace existing files/folders in .
    Use --upgrade to replace existing packages in with new versions.


    Upgrade pip if target switch is not available:

    On Linux or OS X:

    pip install -U pip
    

    On Windows (this works around an issue):

    python -m pip install -U pip
    

提交回复
热议问题