I am trying to install the pymemcache on Ubuntu 17.04 using pip and I get the below error. The module gets installed without the -t option though. But, I want to install the module in a specific directory, so that I can package and upload to Cloud.

Could someone please help me out?

pip install -t /home/praveen/Code/AWS/Lambda/Memcached-Py pymemcache

Collecting pymemcache
    Using cached pymemcache-1.4.3-py2.py3-none-any.whl
Collecting six (from pymemcache)
    Using cached six-1.10.0-py2.py3-none-any.whl
Installing collected packages: six, pymemcache
Traceback (most recent call last):
    File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 215, in main
        status = self.run(options, args)
    File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 360, in run
    File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 784, in install
    File "/usr/lib/python2.7/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/python2.7/dist-packages/pip/req/req_install.py", line 1064, in move_wheel_files
    File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 247, in move_wheel_files
    File "/usr/lib/python2.7/dist-packages/pip/locations.py", line 153, in distutils_scheme
    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
  • I suspect your pip is outdated. Try running python -m pip install -t /home/praveen/Code/AWS/Lambda/Memcached-Py pymemcache.
    – edwinksl
    Jun 12, 2017 at 10:29
  • @edwinksl - I also thought it was something to do with the pip version, but the pip -V command returned me pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7). So, the pip is the latest version. Jun 12, 2017 at 10:53
  • Ah okay. Looks like this is due to a conflict between the explicit -t option and the implicit --user option that is present in Ubuntu's patched version of pip. See github.com/pypa/pip/issues/3826 and github.com/pypa/pip/issues/4390. To circumvent this, I would suggest using a virtualenv instead; I tried it and it works. I could write a more detailed answer if you would like to go down the path of using virtualenv.
    – edwinksl
    Jun 12, 2017 at 11:30
  • Or you could try the --system option as mentioned in github.com/pypa/pip/issues/3826#issuecomment-232080694.
    – edwinksl
    Jun 12, 2017 at 11:39
  • I tried it using virtualenv after posting here and it worked. Jun 12, 2017 at 12:21

1 Answer 1


This problem is caused by a conflict between the explicit -t option and the implicit --user option that is present in Ubuntu's patched version of pip. This is described in pip's GitHub repository at https://github.com/pypa/pip/issues/3826 and https://github.com/pypa/pip/issues/4390.

To circumvent this, I would suggest using a virtualenv. The steps are as follows:

  1. Install virtualenv if you haven't:

    sudo apt update
    sudo apt install virtualenv
  2. Create and activate a virtualenv and upgrade pip:

    virtualenv venv
    source venv/bin/activate
    pip install -U pip
  3. Install pymemcache in your specified directory using the -t option:

    pip install -t /home/praveen/Code/AWS/Lambda/Memcached-Py pymemcache

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.