pypa/pip

--target does not work with --user

dholth opened this issue · 15 comments

On Ubuntu 16.04, pip 8.1.1, --user is default, and --target does not work. Is there any reason to not just have an explicit command line argument --target override implicit --user? Needed for a setup-requires shim.

  File "/usr/lib/python2.7/distutils/command/install.py", line 289, in finalize_options
    raise DistutilsOptionError("can't combine user with prefix, "
DistutilsOptionError: can't combine user with prefix, exec_prefix/home, or install_(plat)base

well, its more of an ubuntu bug, they blindly patch things and then the world breaks ^^

Got bitten by this today (Debian 9), officially Debian mentions #1668 as reason of applying this patch. The official work-around is to use the --system parameter to disable --user, but that will break whenever Debian's pip3 is not used. 😡

Yea, I told Debian/Ubuntu not to apply said patch until we got all the issues worked out with it, they didn't want to wait on that. You'll need to raise the issue with them since their patch is causing the issue.

The underlying issue here is that it's non-sensical for --target and --user to be used on the same command line, but the current setup doesn't make it easy to determine where a particular value came from. We're currently relying on our default of --user to not being on, and by switching the default Debuntu has broken an assumption we've made throughout the code base.

But please, file an issue with bugs.debian.org so that downstream can track issues with their patch and can get this resolved for you.

reported

I have a related issue for the same reason :

$ cat /etc/issue
Ubuntu 16.04.1 LTS \n \l
$ uname -a
Linux kinetic-VirtualBox 4.4.0-31-generic #50-Ubuntu SMP Wed Jul 13 00:07:12 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
$ pip install -r requirements.txt --prefix test_loc/
ERROR: Can not combine '--user' and '--prefix' as they imply different installation locations
You are using pip version 8.1.1, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

Note this might be relevant to #1668 as well, since, even if --user is default, I may want to redirect where python packages get installed...
I believe the same is true for --target.

Or should I create a separate issue for this ?

So does Ubuntu 16.10 fix that?

@dholth could you link to the issue on debian?

To me all three --user, --system and --target are mutually exclusive. Any explicit option should change the default and not depend on that.

This patch should clarify the message for users af03a65

Closing to move a bunch of related issues to a single issue: #4390.

What is the workaround? I want target to take precedence and ignore any other inputs. Hmm.
pip install -r requirements.txt -t lib/ -- OK, found the workaround. It's adding --system
so
pip install -r requirements.txt --system -t lib/ thx!

I am having the same issue on Ubuntu 18.04.1 LTS, but it is working with --system flag.

master└─ $ cat /etc/issue
Ubuntu 18.04.1 LTS \n \l
master└─ $ uname -a
Linux 4.15.0-43-generic #46-Ubuntu SMP Thu Dec 6 14:45:28 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

requirements:

master└─ $ cat requirements-lambda.txt 
logger==1.4
requests==2.18.4
slackclient==1.2.1
elasticsearch==6.0.0
kafka==1.3.5

Exception:

sent 320,716 bytes  received 435 bytes  642,302.00 bytes/sec
total size is 319,089  speedup is 0.99
Collecting logger==1.4 (from -r requirements-lambda.txt (line 1))
Collecting requests==2.18.4 (from -r requirements-lambda.txt (line 2))
  Using cached https://files.pythonhosted.org/packages/49/df/50aa1999ab9bde74656c2919d9c0c085fd2b3775fd3eca826012bef76d8c/requests-2.18.4-py2.py3-none-any.whl
Collecting slackclient==1.2.1 (from -r requirements-lambda.txt (line 3))
Collecting elasticsearch==6.0.0 (from -r requirements-lambda.txt (line 4))
  Using cached https://files.pythonhosted.org/packages/7a/06/4138270b44512484b3ddda7ff4a38e150cfc17a63ef3b2fa7e8c0b18029d/elasticsearch-6.0.0-py2.py3-none-any.whl
Collecting kafka==1.3.5 (from -r requirements-lambda.txt (line 5))
  Using cached https://files.pythonhosted.org/packages/21/71/73286e748ac5045b6a669c2fe44b03ac4c5d3d2af9291c4c6fc76438a9a9/kafka-1.3.5-py2.py3-none-any.whl
Collecting idna<2.7,>=2.5 (from requests==2.18.4->-r requirements-lambda.txt (line 2))
  Using cached https://files.pythonhosted.org/packages/27/cc/6dd9a3869f15c2edfab863b992838277279ce92663d334df9ecf5106f5c6/idna-2.6-py2.py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests==2.18.4->-r requirements-lambda.txt (line 2))
  Using cached https://files.pythonhosted.org/packages/9f/e0/accfc1b56b57e9750eba272e24c4dddeac86852c2bebd1236674d7887e8a/certifi-2018.11.29-py2.py3-none-any.whl
Collecting urllib3<1.23,>=1.21.1 (from requests==2.18.4->-r requirements-lambda.txt (line 2))
  Using cached https://files.pythonhosted.org/packages/63/cb/6965947c13a94236f6d4b8223e21beb4d576dc72e8130bd7880f600839b8/urllib3-1.22-py2.py3-none-any.whl
Collecting chardet<3.1.0,>=3.0.2 (from requests==2.18.4->-r requirements-lambda.txt (line 2))
  Using cached https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl
Collecting websocket-client<1.0a0,>=0.35 (from slackclient==1.2.1->-r requirements-lambda.txt (line 3))
  Using cached https://files.pythonhosted.org/packages/26/2d/f749a5c82f6192d77ed061a38e02001afcba55fe8477336d26a950ab17ce/websocket_client-0.54.0-py2.py3-none-any.whl
Collecting six<2.0a0,>=1.10 (from slackclient==1.2.1->-r requirements-lambda.txt (line 3))
  Using cached https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Installing collected packages: logger, idna, certifi, urllib3, chardet, requests, six, websocket-client, slackclient, elasticsearch, kafka
Exception:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 360, in run
    prefix=options.prefix_path,
  File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 784, in install
    **kwargs
  File "/usr/lib/python3/dist-packages/pip/req/req_install.py", line 851, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/usr/lib/python3/dist-packages/pip/req/req_install.py", line 1064, in move_wheel_files
    isolated=self.isolated,
  File "/usr/lib/python3/dist-packages/pip/wheel.py", line 247, in move_wheel_files
    prefix=prefix,
  File "/usr/lib/python3/dist-packages/pip/locations.py", line 153, in distutils_scheme
    i.finalize_options()
  File "/usr/lib/python3.6/distutils/command/install.py", line 274, in finalize_options
    raise DistutilsOptionError("can't combine user with prefix, "
distutils.errors.DistutilsOptionError: can't combine user with prefix, exec_prefix/home, or install_(plat)base
lock commented

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.