Install a Python package into a different directory using pip?

后端 未结 16 2445
借酒劲吻你
借酒劲吻你 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:16

    Tested these options with python3.5 and pip 9.0.3:

    pip install --target /myfolder [packages]

    Installs ALL packages including dependencies under /myfolder. Does not take into account that dependent packages are already installed elsewhere in Python. You will find packages from /myfolder/[package_name]. In case you have multiple Python versions, this doesn't take that into account (no Python version in package folder name).

    pip install --prefix /myfolder [packages]

    Checks are dependencies already installed. Will install packages into /myfolder/lib/python3.5/site-packages/[packages]

    pip install --root /myfolder [packages]

    Checks dependencies like --prefix but install location will be /myfolder/usr/local/lib/python3.5/site-packages/[package_name].

    pip install --user [packages]

    Will install packages into $HOME: /home/[USER]/.local/lib/python3.5/site-packages Python searches automatically from this .local path so you don't need to put it to your PYTHONPATH.

    => In most of the cases --user is the best option to use. In case home folder can't be used because of some reason then --prefix.

提交回复
热议问题