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

时光毁灭记忆、已成空白 提交于 2019-11-30 01:48:24
Theja

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.

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....

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
Proddi

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

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.

Yuriy R

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.

Melissa

This worked:

mv /usr/lib/python2.7/site-packages/pip* ./
yum reinstall python-pip
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!