Install Python packages to the current directory using PIP in Ubuntu 18
PIP has a --target option to define the target location to install the modules. But for some reason, it was not working and kept giving me the following error. It seems PIP uses the user scheme by default to install and when I use --target, it throws an error.
distutils.errors.DistutilsOptionError: can't combine user with prefix, exec_prefix/home, or install_(plat)base
After searching for a while, I found a workaround and got it working. Here's how to do that. PIP also has another option as --system, it actually disables the user scheme option. That was it. But this option was not listed in pip man page.
Anyway, the final command should look like this:
pip install --system --target <target-dir> <package-name>
Ex:
pip install --system --target ./ pexpect
Hope this post will save someone's time :)