Pip/Python six.add_metaclass error

0

I have had this issue for about a week now in which I cannot use the pip command in any way without getting the same error string. I have been unable to tie it to anything I have found online and have had little luck fixing it. When I use the pip command I recieve this error.

Traceback (most recent call last):
  File "/usr/local/bin/pip2.7", line 7, in <module>
    from pip._internal import main
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/__init__.py", line 42, in <module>
    from pip._internal import cmdoptions
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/cmdoptions.py", line 16, in <module>
    from pip._internal.index import (
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/index.py", line 15, in <module>
    from pip._vendor import html5lib, requests, six
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py", line 86, in <module>
    from pip._vendor.urllib3.contrib import pyopenssl
  File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in <module>
    import OpenSSL.SSL
  File "/usr/local/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import rand, crypto, SSL
  File "/usr/local/lib/python2.7/dist-packages/OpenSSL/crypto.py", line 13, in <module>
    from cryptography.hazmat.primitives.asymmetric import dsa, rsa
  File "/usr/local/lib/python2.7/dist-packages/cryptography/hazmat/primitives/asymmetric/__init__.py", line 12, in <module>
    @six.add_metaclass(abc.ABCMeta)
AttributeError: 'module' object has no attribute 'add_metaclass'

After several days of searching I finally went into the python2.7/dist-utils/ folder and manually deleted any remnants of pip or Python that I found, deleted all shortcuts and cache files and reinstalled the entire thing. For about 5 hours everyone worked just fine and then the error began again right in between uses of pip. Can anyone help me to find out what may the source of this error. Below is the command history of my actions right as the issue began again.

sudo python2.7 setup.py install
pip install tldextract
sudo pip install tldextract
sudo pip install isodate
sudo pip install orderddict
sudo pip install ordereddict
sudo pip install backports-abc
sudo pip install pymal --upgrade
sudo python2.7 setup.py install
***This is where the issue started again***
cd Transforms/
cd Domain/
sudo python2.7 spf.py install
sudo pip spf.py 
sudo pip2.7 spf.py 
pip list
sudo pip install pymal -U
sudo pip install pymal -u
sudo pip2.7
sudo pip2.7 dmarc.py 

The Pymal update seems the obvious culprit, I had tried to upgrade the pymal module in the days before but could not due to the meta_class error that has now started again. Any help is appreciated.

Greg

Posted 2018-06-14T05:17:13.497

Reputation: 11

Answers

1

I found the answer to my issue. Apparently some linux versions have specific versions of pip and six that have to be installed through the distro package manager directly in order to work. There are some nuanced changes in how Debian makes use of pip, especially regarding updates, and they have coded these changes in to their package manager and not to pip. When I recompiled Python I had uninstalled the entire python framework and I went to the source url's to recombine python and to download pip and any other dependencies. I figured since I was installing directly from the source that it would be fine... If you are using CentOS, Debian,Redhat and maybe others, then you must install pip from the package manager that is managed by your distro in order to avoid running into this error somewhere down the line.

Greg

Posted 2018-06-14T05:17:13.497

Reputation: 11