Ubuntu pip is broken - python

Ubuntu 4.4.0-176-generic
when I run pip or pip3 I get:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 9, in <module>
load_entry_point('pip==1.5.6', 'console_scripts', 'pip')()
File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 356, in load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 2476, in load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 2190, in load
File "/usr/local/lib/python2.7/dist-packages/pip/__init__.py", line 11, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/local/lib/python2.7/dist-packages/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/usr/local/lib/python2.7/dist-packages/pip/download.py", line 22, in <module>
from pip._vendor import requests, six
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py", line 53, in <module>
from .packages.urllib3.contrib import pyopenssl
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/contrib/pyopenssl.py", line 70, in <module>
ssl.PROTOCOL_SSLv3: OpenSSL.SSL.SSLv3_METHOD,
AttributeError: 'module' object has no attribute 'PROTOCOL_SSLv3'
Many of the solutions indicate that I need to install a different version of requests, however, I cannot do that because I can't use pip.

When facing this problem, I removed pip using
apt remove python3-pip
and installed it again and it fixed my problem.

Related

Pip not working in my system,

I am getting the following error while using pip command, in anaconda.
C:\Users\name>pip install xmlschema
Traceback (most recent call last):
File "C:\ANACONDA2\Scripts\pip-script.py", line 9, in <module>
load_entry_point('pip==9.0.1', 'console_scripts', 'pip')()
File "C:\ANACONDA2\lib\site-packages\setuptools-18.4-py2.7.egg\pkg_resources\__init__.py", line 558, in load_entry_point
File "C:\ANACONDA2\lib\site-packages\setuptools-18.4-py2.7.egg\pkg_resources\__init__.py", line 2682, in load_entry_point
File "C:\ANACONDA2\lib\site-packages\setuptools-18.4-py2.7.egg\pkg_resources\__init__.py", line 2355, in load
File "C:\ANACONDA2\lib\site-packages\setuptools-18.4-py2.7.egg\pkg_resources\__init__.py", line 2361, in resolve
File "c:\anaconda2\lib\site-packages\pip\__init__.py", line 28, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "c:\anaconda2\lib\site-packages\pip\vcs\subversion.py", line 9, in <module>
from pip.index import Link
File "c:\anaconda2\lib\site-packages\pip\index.py", line 33, in <module>
from pip._vendor import html5lib, requests, six
File "c:\anaconda2\lib\site-packages\pip\_vendor\html5lib\__init__.py", line 19, in <module>
from .serializer import serialize
File "c:\anaconda2\lib\site-packages\pip\_vendor\html5lib\serializer\__init__.py", line 5, in <module>
from .htmlserializer import HTMLSerializer
File "c:\anaconda2\lib\site-packages\pip\_vendor\html5lib\serializer\htmlserializer.py", line 11, in <module>
from .. import utils
ImportError: cannot import name utils
I am having utils package, but still throwing ImportError: cannot import name utils
On windows there is no sudo command. You have to run the command line as administrator and run the pip commands from above without sudo.
you can try this commands to fix it:
pip uninstall requests
pip install --upgrade requests
if you have trouble about to execute pip command on windows, check this link

Pip disabled after trying to upgrade Openssl

I've been trying to use tweepy which requieres pyOpenssl, but after trying to upgrade Openssl I'm getting this error which actually disable my pip for any package
$ pip install cryptography
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
load_entry_point('pip==1.5.6', 'console_scripts', 'pip')()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 565, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2598, in load_entry_point
return ep.load()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2258, in load
return self.resolve()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2264, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 74, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/lib/python2.7/dist-packages/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/usr/lib/python2.7/dist-packages/pip/download.py", line 22, in <module>
import requests, six
File "/usr/lib/python2.7/dist-packages/requests/__init__.py", line 68, in <module>
_attach_namespace(urllib3, 'requests.packages')
File "/usr/lib/python2.7/dist-packages/requests/__init__.py", line 63, in _attach_namespace
module = __import__(name)
File "/usr/lib/python2.7/dist-packages/urllib3/contrib/pyopenssl.py", line 55, 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/SSL.py", line 112, in <module>
if _lib.Cryptography_HAS_SSL_ST:
AttributeError: 'FFILibrary' object has no attribute 'Cryptography_HAS_SSL_ST'
Now, as I said, I can't install anything since this error keeps apearing. I already tried to follow the recomendation on the following link but without any success
How to install cryptography on ubuntu?
The version of python is 2.7 and linux is debian
Thanks

centos 6.8 pip install error HTTPSHandler

hello I have a problem about pip install error
when I type the pip in the terminal, it returns this message
Traceback (most recent call last):
File "/usr/local/python2.7//bin/pip", line 9, in <module>
load_entry_point('pip==8.1.1', 'console_scripts', 'pip')()
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 542, in load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2569, in load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2229, in load
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2235, in resolve
File "/usr/local/python2.7/lib/python2.7/site-packages/pip-8.1.1-py2.7.egg/pip/__init__.py", line 16, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/local/python2.7/lib/python2.7/site-packages/pip-8.1.1-py2.7.egg/pip/vcs/subversion.py", line 9, in <module>
from pip.index import Link
File "/usr/local/python2.7/lib/python2.7/site-packages/pip-8.1.1-py2.7.egg/pip/index.py", line 30, in <module>
from pip.wheel import Wheel, wheel_ext
File "/usr/local/python2.7/lib/python2.7/site-packages/pip-8.1.1-py2.7.egg/pip/wheel.py", line 39, in <module>
from pip._vendor.distlib.scripts import ScriptMaker
File "/usr/local/python2.7/lib/python2.7/site-packages/pip-8.1.1-py2.7.egg/pip/_vendor/distlib/scripts.py", line 14, in <module>
from .compat import sysconfig, detect_encoding, ZipFile
File "/usr/local/python2.7/lib/python2.7/site-packages/pip-8.1.1-py2.7.egg/pip/_vendor/distlib/compat.py", line 31, in <module>
from urllib2 import (Request, urlopen, URLError, HTTPError,
ImportError: cannot import name HTTPSHandler
How can I do to solve this?
ImportError: cannot import name HTTPSHandler error most of the time is caused by using Python interpreter without support for SSL. See Building Python with SSL support in non-standard location

How to install requests module for Python 3.1 ubuntu server 10.04?

I have a ubuntu server.(10.04)
I don't install requests module. I try pip and other methods. Usually ;
$ sudo pip install requests
Traceback (most recent call last):
File "/usr/local/lib/python3.1/dist-packages/pip-1.5.5-py3.1.egg/pip/_vendor/requests/packages/urllib3/packages/ssl_match_hostname/__init__.py", line 3, in <module>
from ssl import CertificateError, match_hostname
ImportError: cannot import name CertificateError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.1/dist-packages/pip-1.5.5-py3.1.egg/pip/_vendor/requests/packages/urllib3/packages/ssl_match_hostname/__init__.py", line 7, in <module>
from backports.ssl_match_hostname import CertificateError, match_hostname
ImportError: No module named backports.ssl_match_hostname
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 9, in <module>
load_entry_point('pip==1.5.5', 'console_scripts', 'pip')()
File "/usr/local/lib/python3.1/dist-packages/distribute-0.6.49-py3.1.egg/pkg_resources.py", line 345, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python3.1/dist-packages/distribute-0.6.49-py3.1.egg/pkg_resources.py", line 2382, in load_entry_point
return ep.load()
File "/usr/local/lib/python3.1/dist-packages/distribute-0.6.49-py3.1.egg/pkg_resources.py", line 2088, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/local/lib/python3.1/dist-packages/pip-1.5.5-py3.1.egg/pip/__init__.py", line 11, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/local/lib/python3.1/dist-packages/pip-1.5.5-py3.1.egg/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/usr/local/lib/python3.1/dist-packages/pip-1.5.5-py3.1.egg/pip/download.py", line 22, in <module>
from pip._vendor import requests, six
File "/usr/local/lib/python3.1/dist-packages/pip-1.5.5-py3.1.egg/pip/_vendor/requests/__init__.py", line 58, in <module>
from . import utils
File "/usr/local/lib/python3.1/dist-packages/pip-1.5.5-py3.1.egg/pip/_vendor/requests/utils.py", line 25, in <module>
from .compat import parse_http_list as _parse_list_header
File "/usr/local/lib/python3.1/dist-packages/pip-1.5.5-py3.1.egg/pip/_vendor/requests/compat.py", line 7, in <module>
from .packages import chardet
File "/usr/local/lib/python3.1/dist-packages/pip-1.5.5-py3.1.egg/pip/_vendor/requests/packages/__init__.py", line 3, in <module>
from . import urllib3
File "/usr/local/lib/python3.1/dist-packages/pip-1.5.5-py3.1.egg/pip/_vendor/requests/packages/urllib3/__init__.py", line 16, in <module>
from .connectionpool import (
File "/usr/local/lib/python3.1/dist-packages/pip-1.5.5-py3.1.egg/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 31, in <module>
from .packages.ssl_match_hostname import CertificateError
File "/usr/local/lib/python3.1/dist-packages/pip-1.5.5-py3.1.egg/pip/_vendor/requests/packages/urllib3/packages/__init__.py", line 3, in <module>
from . import ssl_match_hostname
File "/usr/local/lib/python3.1/dist-packages/pip-1.5.5-py3.1.egg/pip/_vendor/requests/packages/urllib3/packages/ssl_match_hostname/__init__.py", line 10, in <module>
from _implementation import CertificateError, match_hostname
ImportError: No module named _implementation
I guess I have already setup pip 3.1. But following
$ pip -V
Then I see same problem. How to install requests module for Python 3.1 ubuntu server 10.04?
Have you tried easy_install requests?
Or you could try a non-fancy way. Google requests package, download it, unzip it and then run setup.py script like this:
python setup.py install
Have you tried pip install backports.ssl-match-hostname
Probably no harm to upgrade Python either.

python fabric error 'module' object has no attribute 'HAVE_DECL_MPZ_POWM_SEC'

I am getting following error when I run fabric
(ENV)[root#server-124 ENV]# fab
Traceback (most recent call last):
File "/usr/bin/fab", line 9, in <module>
load_entry_point('Fabric==1.8.3', 'console_scripts', 'fab')()
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 299, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 2229, in load_entry_point
return ep.load()
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 1948, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/lib/python2.6/site-packages/fabric/main.py", line 19, in <module>
from fabric import api, state, colors
File "/usr/lib/python2.6/site-packages/fabric/api.py", line 9, in <module>
from fabric.context_managers import (cd, hide, settings, show, path, prefix,
File "/usr/lib/python2.6/site-packages/fabric/context_managers.py", line 42, in <module>
from fabric.state import output, win32, connections, env
File "/usr/lib/python2.6/site-packages/fabric/state.py", line 9, in <module>
from fabric.network import HostConnectionCache, ssh
File "/usr/lib/python2.6/site-packages/fabric/network.py", line 24, in <module>
import paramiko as ssh
File "/usr/lib/python2.6/site-packages/paramiko/__init__.py", line 31, in <module>
from transport import SecurityOptions, Transport
File "/usr/lib/python2.6/site-packages/paramiko/transport.py", line 33, in <module>
from paramiko import util
File "/usr/lib/python2.6/site-packages/paramiko/util.py", line 33, in <module>
from paramiko.common import *
File "/usr/lib/python2.6/site-packages/paramiko/common.py", line 98, in <module>
from Crypto import Random
File "/usr/lib64/python2.6/site-packages/Crypto/Random/__init__.py", line 29, in <module>
from Crypto.Random import _UserFriendlyRNG
File "/usr/lib64/python2.6/site-packages/Crypto/Random/_UserFriendlyRNG.py", line 38, in <module>
from Crypto.Random.Fortuna import FortunaAccumulator
File "/usr/lib64/python2.6/site-packages/Crypto/Random/Fortuna/FortunaAccumulator.py", line 39, in <module>
import FortunaGenerator
File "/usr/lib64/python2.6/site-packages/Crypto/Random/Fortuna/FortunaGenerator.py", line 34, in <module>
from Crypto.Util.number import ceil_shift, exact_log2, exact_div
File "/usr/lib64/python2.6/site-packages/Crypto/Util/number.py", line 56, in <module>
if _fastmath is not None and not _fastmath.HAVE_DECL_MPZ_POWM_SEC:
AttributeError: 'module' object has no attribute 'HAVE_DECL_MPZ_POWM_SEC'
I have referred some other post that says it "so you'reusing a newer version of PyCrypto with an older version of _fastmath." So I also installed gmp-devel
I am using virtualenv , Centos 6, Python 2.6
please help.
This fixed it for me:
pip install PyCrypto==2.3
I didn't uninstall python-crypto because other packages I needed depended on it. I just ran the pip command above and everything worked :)

Categories