pip fails with AttributeError: 'module' object has no attribute 'wraps'
Asked Answered
F

7

21

I'm on Fedora. I recently upgraded my system from F20 to F21. Pip was working fine on F20 but after the upgrade to F21 something must have gone wrong. Pip stopped working, every time I enter the command pip <anything> the error below occurs:

Traceback (most recent call last):
  File "/usr/bin/pip", line 7, in <module>
    from pip import main
  File "/usr/lib/python2.7/site-packages/pip/__init__.py", line 12, in <module>
    from pip.commands import commands, get_summaries, get_similar_commands
  File "/usr/lib/python2.7/site-packages/pip/commands/__init__.py", line 6, in <module>
    from pip.commands.bundle import BundleCommand
  File "/usr/lib/python2.7/site-packages/pip/commands/bundle.py", line 6, in <module>
    from pip.commands.install import InstallCommand
  File "/usr/lib/python2.7/site-packages/pip/commands/install.py", line 5, in <module>
    from pip.req import InstallRequirement, RequirementSet, parse_requirements
  File "/usr/lib/python2.7/site-packages/pip/req/__init__.py", line 3, in <module>
    from .req_install import InstallRequirement
  File "/usr/lib/python2.7/site-packages/pip/req/req_install.py", line 31, in <module>
    from pip.utils import (
  File "/usr/lib/python2.7/site-packages/pip/utils/__init__.py", line 59, in <module>
    def rmtree(dir, ignore_errors=False):
  File "/usr/lib/python2.7/site-packages/pip/_vendor/retrying.py", line 47, in wrap
    @six.wraps(f)
AttributeError: 'module' object has no attribute 'wraps'
Frankie answered 13/3, 2015 at 17:57 Comment(8)
do you have two versions of six?Emeliaemelin
I'm not sure. How do I go about checking that without pip list?Frankie
pip show six , have you tried pip install -U six?Emeliaemelin
pip doesn't seem to work. Any command to do with pip shows the above error.Frankie
sorry yes, have you tried reinstalling pip? bootstrap.pypa.io/get-pip.pyEmeliaemelin
wraps was added to six in 1.7 (current version is 1.9). It looks like you somehow reverted to an older version of six. Or you have two versions of six and you're now pointed at the wrong one.Jactitation
@PadraicCunningham yes tried that several times. After removing pip and doing python get-pip.py the following is shown: Requirement already up-to-date: pip in /usr/lib/python2.7/site-packagesFrankie
@StevenRumbalski how do I correct that?Frankie
F
14

Okay after trying out all the solutions I could google with no result in sight. I tried to risk and play a little bit. This might not be the safest solution but it worked fine for me. Seeing that python get-pip.py resulted in:

Requirement already up-to-date: pip in /usr/lib/python2.7/site-packages

even when I had pip uninstalled. I went over to /usr/lib/python2.7/site-packages/ to find out two pip directories: pip and pip-6.0.8.dist-info. Removed both immediately. Then tried python get-pip.py again. Voila! it worked.

Frankie answered 13/3, 2015 at 19:7 Comment(1)
This worked for me too, but I had to delete the existing pip package from my virtualenv, not the global Python dist-packages.Certiorari
K
8

Use easy_install to install a prior version of pip

easy_install pip==7.0.2

Then use pip to install the version you came down from, in my case it was 9.0.1

pip install pip==9.0.1
Keloid answered 4/4, 2017 at 15:33 Comment(0)
U
7

happend to me on windows with activestate python fresh install I've just used easy_install to downgrade the pip

easy_install pip==7.1.2

and then it was working....

Unwashed answered 8/6, 2016 at 14:33 Comment(0)
P
5

If you recreate a virtual env that contains a different pip-version you can run into such a scenario:

# virtualenv /tmp/env
New python executable in /tmp/env/bin/python
Installing setuptools, pip...done.

# /tmp/env/bin/pip install --upgrade pip
(...)
Found existing installation: pip 1.5.6
  Uninstalling pip:
    Successfully uninstalled pip
Successfully installed pip

# virtualenv /tmp/env
New python executable in /tmp/env/bin/python
Installing setuptools, pip...done.

# /tmp/env/bin/pip install --upgrade pip
(...)
AttributeError: 'module' object has no attribute 'wraps'

The environment now contains the pip fragments from the previous installation. To fix that you can use the --clean option:

# virtualenv --clear /tmp/env
Deleting tree /tmp/env/lib/python2.7
Not deleting /tmp/env/bin
New python executable in /tmp/env/bin/python
Installing setuptools, pip...done.

Then virtualenv will wipe out the path before it installs the new environment.

If you wanna have an update behavior you can skip virtualenv if (e.g.) bin/python) is present.

# [ ! -x /tmp/env/bin/python ] && virtualenv /tmp/env
Pyszka answered 1/8, 2016 at 16:58 Comment(0)
B
1

This occurred in my situation after I had moved the virtualenv directory (along with the project) to a new location, which I clearly shouldn't have done as (reading the doc now) the manual clearly states some [full] hardcoded paths are included in the environment.

Deleting the bin/, include/, lib/ and lib64/ directories and then recreating the virtualenv solved the issue for me.

I did look into searching for and fixing the full paths in the environment, but fixing it everywhere (besides in the bin/activate* files) didn't seem trivial.

Bronny answered 15/2, 2016 at 17:40 Comment(0)
V
0

This worked:

mv /usr/lib/python2.7/site-packages/pip* ./
yum reinstall python-pip
Voile answered 12/5, 2015 at 0:21 Comment(0)
S
0

I'm on Mac OS, but was able to fix this error by doing mkvirtualenv --system-site-packages XXXX as opposed to mkvirtualenv XXXX.

Running pip install -r requirements.txt in the virtual environment was giving me AttributeError: 'module' object has no attribute 'wraps' before and doesn't anymore.

Stereoscope answered 18/10, 2016 at 10:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.