Pip Error : 'module' object has no attribute 'Cryptography_HAS_SSL_ST' - python

I tried to install from pip and keep on getting similar type of errors.
$ pip install quandl
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/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 558, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2682, in load_entry_point
return ep.load()
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2355, in load
return self.resolve()
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2361, 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 53, in <module>
from .packages.urllib3.contrib import pyopenssl
File "/usr/lib/python2.7/dist-packages/urllib3/contrib/pyopenssl.py", line 53, in <module>
import OpenSSL.SSL
File "/home/ubuntu/.local/lib/python2.7/site-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/home/ubuntu/.local/lib/python2.7/site-packages/OpenSSL/SSL.py", line 112, in <module>
if _lib.Cryptography_HAS_SSL_ST:
AttributeError: 'module' object has no attribute 'Cryptography_HAS_SSL_ST'
Now even though i tried to install different pip modules iam getting same error.Is there any solution for this ? This was caused due to the unexpected killing of the process while a pip module is being downloaded.
Please help me with the necessary steps to rectify this error.
I tried to install this
$ pip install -U 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/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 558, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2682, in load_entry_point
return ep.load()
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2355, in load
return self.resolve()
File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2361, 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 53, in <module>
from .packages.urllib3.contrib import pyopenssl
File "/usr/lib/python2.7/dist-packages/urllib3/contrib/pyopenssl.py", line 53, in <module>
import OpenSSL.SSL
File "/home/ubuntu/.local/lib/python2.7/site-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/home/ubuntu/.local/lib/python2.7/site-packages/OpenSSL/SSL.py", line 112, in <module>
if _lib.Cryptography_HAS_SSL_ST:
AttributeError: 'module' object has no attribute 'Cryptography_HAS_SSL_ST'

Ubuntu 16.04.3 here:
I think I have fixed this by removing the python-openssl package (and it's dependencies) with:
apt-get --auto-remove remove python-openssl
Then installing the latest version with pip:
pip install pyOpenSSL
Of course, if you install another apt package that depends on it, it'll pull it back in. I hope if you use pip for everything you can from now on instead of apt, it should be fine.
Edit: as of January 2019 this issue doesn't seem to exist any more.

I was able to resolve this by deleting the openssl python lib and reinstalling (purge before install did not work):
$ sudo rm -rf /usr/local/lib/python2.7/dist-packages/OpenSSL/
$ sudo apt install --reinstall python-openssl

If even pip is not working then try following:
sudo easy_install -U cffi
sudo easy_install -U cryptography
It works for me.

To fix it on RHEL/CentOS:
sudo rm -rf /usr/lib/python2.7/site-packages/OpenSSL/
sudo yum install pyOpenSSL
This did it for me on CentOS 7. Cheers!

I got this error and solved it by doing these steps (don't forget to put your own username):
rm -rf /home/<Your Username>/.local/lib/python2.7/site-packages/OpenSSL
sudo rm -rf usr/local/lib/python2.7/dist-packages/OpenSSL/
pip install pyOpenSSL

Try to do the following:
$ rm -rf /home/ubuntu/.local/lib/python2.7/site-packages/OpenSSL
$ rm -rf /home/ubuntu/.local/lib/python2.7/site-packages/pyOpenSSL-0.15.1.egg-info
In the last line, you might have another version of pyOpenSSL, specify yours.

Quick Fix
Move the OpenSSL folder to OpenSSLBAK (for instance) to avoid the error
# cd /usr/lib/python2.7/dist-packages
# mv OpenSSL OpenSSLBAK
It should be good

Try reinstalling python of which will fix many of your problems,do
sudo apt-get install --reinstall python2.7
and pip will be missing after reinstalling,do
sudo apt-get install python-pip

Try to download the suitable wheel file from here depending in your operating system and python version. Then add this file to Python/Scripts and use the code below to install it.
pip install nameofwheelfile.whl
The wheel file contains all the dependencies.

Related

An error message when execute pip

I am confused on python on its installation path and configuration.
I know pip this command for installation or listing the modules.
The example is like pip freeze. It will show up the list of module.
Recently, I got an error when I execute pip. I had python2 and python3 on the system without any virtualenv. I use ls /usr/bin/python* -al | awk {print $9 $10 $11} to know python commands and ls /usr/bin/pip* -al to know the pip commands.
python->python2.7
python2->python2.7
python2.7
python2.7-config->arm-linux-gnueabihf-python2.7-config
python2-config->python2.7-config
python3->python3.4
python3.4
python3.4m
python3m->python3.4m
python-config->python2.7-config
pip pip2 pip3
In addition, I use ls on /usr/local/bin and know the pip commands.
pip pip2 pip2.7 pip3 pip3.4 pip3.5
The error message is this when I execute pip.
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 11, in <module>
load_entry_point('pip==9.0.1', 'console_scripts', 'pip3')()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 572, 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 2752, in load_entry_point
return ep.load()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2405, in load
return self.resolve()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2411, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/local/lib/python2.7/dist-packages/pip/__init__.py", line 76, in <module>
from pip.commands import commands, get_summaries, get_similar_commands
File "/usr/local/lib/python2.7/dist-packages/pip/commands/__init__.py", line 6, in <module>
from pip.commands.bundle import BundleCommand
File "/usr/local/lib/python2.7/dist-packages/pip/commands/bundle.py", line 6, in <module>
from pip.commands.install import InstallCommand
File "/usr/local/lib/python2.7/dist-packages/pip/commands/install.py", line 5, in <module>
from pip.req import InstallRequirement, RequirementSet, parse_requirements
File "/usr/local/lib/python2.7/dist-packages/pip/req/__init__.py", line 3, in <module>
from .req_install import InstallRequirement
File "/usr/local/lib/python2.7/dist-packages/pip/req/req_install.py", line 42, in <module>
from pip.utils.hashes import Hashes
File "/usr/local/lib/python2.7/dist-packages/pip/utils/hashes.py", line 5, in <module>
from pip.exceptions import HashMismatch, HashMissing, InstallationError
ImportError: cannot import name HashMissing`
How to resolve this error? Why does the system show up the error?
The result is the conflict without a specific command.
Use python2.7 -m pip or python2 -m pip for a specific command. Vice versa, on python3, use python3 -m pip or python3.4 -m pip for a specific command.
In addition, use python or python3 to get into interactive mode. Then, use import sys and sys.path to get the path of python package.

pip error after upgrading pip & scrapy by "pip install --upgrade"

Using debian 8(jessie) amd64 with python 2.7.9. I tried following commands:
pip install --upgrade pip
pip install --upgrade scrapy
after that, I am getting following pip error
root#debian:~# pip
Traceback (most recent call last):
File "/usr/local/bin/pip", line 11, in <module>
load_entry_point('pip==8.1.2', 'console_scripts', 'pip')()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 567, 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 2604, in load_entry_point
return ep.load()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2264, in load
return self.resolve()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2270, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/local/lib/python2.7/dist-packages/pip/__init__.py", line 16, 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 39, 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 54, in <module>
import OpenSSL.SSL
File "/usr/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/usr/lib/python2.7/dist-packages/OpenSSL/rand.py", line 11, in <module>
from OpenSSL._util import (
File "/usr/lib/python2.7/dist-packages/OpenSSL/_util.py", line 4, in <module>
binding = Binding()
File "/usr/lib/python2.7/dist-packages/cryptography/hazmat/bindings/openssl/binding.py", line 89, in __init__
self._ensure_ffi_initialized()
File "/usr/lib/python2.7/dist-packages/cryptography/hazmat/bindings/openssl/binding.py", line 113, in _ensure_ffi_initialized
libraries=libraries,
File "/usr/lib/python2.7/dist-packages/cryptography/hazmat/bindings/utils.py", line 80, in build_ffi
extra_link_args=extra_link_args,
File "/usr/local/lib/python2.7/dist-packages/cffi/api.py", line 437, in verify
lib = self.verifier.load_library()
File "/usr/local/lib/python2.7/dist-packages/cffi/verifier.py", line 114, in load_library
return self._load_library()
File "/usr/local/lib/python2.7/dist-packages/cffi/verifier.py", line 225, in _load_library
return self._vengine.load_library()
File "/usr/local/lib/python2.7/dist-packages/cffi/vengine_cpy.py", line 174, in load_library
lst = list(map(self.ffi._get_cached_btype, lst))
File "/usr/local/lib/python2.7/dist-packages/cffi/api.py", line 409, in _get_cached_btype
BType = type.get_cached_btype(self, finishlist)
File "/usr/local/lib/python2.7/dist-packages/cffi/model.py", line 61, in get_cached_btype
BType = self.build_backend_type(ffi, finishlist)
File "/usr/local/lib/python2.7/dist-packages/cffi/model.py", line 507, in build_backend_type
base_btype = self.build_baseinttype(ffi, finishlist)
File "/usr/local/lib/python2.7/dist-packages/cffi/model.py", line 525, in build_baseinttype
% self._get_c_name())
cffi.api.CDefError: 'point_conversion_form_t' has no values explicitly defined: refusing to guess which integer type it is meant to be (unsigned/signed, int/long)
googled for several similar problem, cffi or cryptography may cause this problem, but i can't find any clear way to fix it.
Got the exact same error today, but in a different situation. I suspect this is related to cryptography module.
What helped me was to install a specific version of cffi package:
pip install cffi==1.7.0
i removed cffi and tried this command to install cffi 1.7.0:
pip install cffi==1.7.0
it worked, thank you, alecxe and moeseth :)
My situation was like #alecxe
This works:
pip install cffi==1.7.0
Had the same problem as moeseth: the pip install something answers are pretty useless when all pip commands throw the original exception. Installing cffi v. 1.7.0 also solved the problem and this is how I managed to do it in Debian Jessie without relying on pip:
Temporarily add testing repos to /etc/apt/sources.list, e.g.,
deb http://ftp.fi.debian.org/debian/ testing main contrib non-free
deb-src http://ftp.fi.debian.org/debian/ testing main contrib non-free
Run sudo apt-get update
Use aptitude or apt-get to upgrade python-cffi and python-cffi-backend to v. 1.7.0
Remove the lines added in step 1. from /etc/apt/sources.list and run sudo apt-get update
So I was in a situation where pip was failing. I had to remove python-cffi and then install it from pip with a correct version
sudo apt-get remove python-cffi
pip install cffi==1.7.0
Works like a charm.

Error when using pip to install

Whenever I try to install anything using pip I get the following error:
$ sudo pip install --upgrade pip
Traceback (most recent call last):
File "/usr/local/bin/pip", line 9, in <module>
load_entry_point('pip==7.0.3', 'console_scripts', 'pip')()
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 558, in load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2682, in load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2355, in load
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2361, in resolve
File "/usr/local/lib/python2.7/site-packages/pip-7.0.3-py2.7.egg/pip/__init__.py", line 15, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/local/lib/python2.7/site-packages/pip-7.0.3-py2.7.egg/pip/vcs/subversion.py", line 9, in <module>
from pip.index import Link
File "/usr/local/lib/python2.7/site-packages/pip-7.0.3-py2.7.egg/pip/index.py", line 30, in <module>
from pip.wheel import Wheel, wheel_ext
File "/usr/local/lib/python2.7/site-packages/pip-7.0.3-py2.7.egg/pip/wheel.py", line 35, in <module>
from pip._vendor.distlib.scripts import ScriptMaker
File "/usr/local/lib/python2.7/site-packages/pip-7.0.3-py2.7.egg/pip/_vendor/__init__.py", line 92, in load_module
raise ImportError("No module named '%s'" % (name,))
ImportError: No module named 'pip._vendor.distlib.scripts'
This also happens when I try to upgrade pip, install sphinx or basically any install/upgrade option using pip.
I am running Ubuntu 15.10 and using Python 2.7.10
StackOverflow has said this is a duplicate, and that there is a solution at ImportError: No module named 'pip._vendor.distlib.scripts' when I try to install fabric by python pip however the recommend solution on this post is not actually a soltuion. It does not solve my issue, nor does it appear to solve the original posters problem.
Try this:
sudo pip install --upgrade --no-use-wheel pip

python3.5 pip ImportError: cannot import name 'HTTPSHandler'

everybody.
Firstly,my OS is RHEL7.2,and I use python3.5.
I want to use pip to do something I want.And then ,after I install pip3 successfully,I want to use pip to install something,but it shows me ImportError: cannot import name 'HTTPSHandler'.And I follow the solution on website to yum install openssl-devel,but it shows the error :
Transaction check error:
file /usr/bin/sclient from install of krb5-devel-1.13.2-10.el7.x86_64 conflicts with file from package krb5-server-1.13.2-10.el7.x86_64
file /usr/sbin/sserver from install of krb5-devel-1.13.2-10.el7.x86_64 conflicts with file from package krb5-server-1.13.2-10.el7.x86_64
I can't solve it independently.I hope you can help me.Thanks.
PS:the whole error message is:
[fen#localhost Downloads]$ pip pip-8.0.2-py2.py3-none-any.whl install
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
load_entry_point('pip==8.1.1', 'console_scripts', 'pip')()
File "/usr/local/python3.5/lib/python3.5/site-packages/setuptools-20.3.1-py3.5.egg/pkg_resources/__init__.py", line 549, in load_entry_point
File "/usr/local/python3.5/lib/python3.5/site-packages/setuptools-20.3.1-py3.5.egg/pkg_resources/__init__.py", line 2542, in load_entry_point
File "/usr/local/python3.5/lib/python3.5/site-packages/setuptools-20.3.1-py3.5.egg/pkg_resources/__init__.py", line 2202, in load
File "/usr/local/python3.5/lib/python3.5/site-packages/setuptools-20.3.1-py3.5.egg/pkg_resources/__init__.py", line 2208, in resolve
File "/usr/local/python3.5/lib/python3.5/site-packages/pip-8.1.1-py3.5.egg/pip/__init__.py", line 16, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/local/python3.5/lib/python3.5/site-packages/pip-8.1.1-py3.5.egg/pip/vcs/subversion.py", line 9, in <module>
from pip.index import Link
File "/usr/local/python3.5/lib/python3.5/site-packages/pip-8.1.1-py3.5.egg/pip/index.py", line 30, in <module>
from pip.wheel import Wheel, wheel_ext
File "/usr/local/python3.5/lib/python3.5/site-packages/pip-8.1.1-py3.5.egg/pip/wheel.py", line 39, in <module>
from pip._vendor.distlib.scripts import ScriptMaker
File "/usr/local/python3.5/lib/python3.5/site-packages/pip-8.1.1-py3.5.egg/pip/_vendor/distlib/scripts.py", line 14, in <module>
from .compat import sysconfig, detect_encoding, ZipFile
File "/usr/local/python3.5/lib/python3.5/site-packages/pip-8.1.1-py3.5.egg/pip/_vendor/distlib/compat.py", line 66, in <module>
from urllib.request import (urlopen, urlretrieve, Request, url2pathname,
ImportError: cannot import name 'HTTPSHandler'
I solved my problem.
I have so many repositories and some data in one repository conflict with another. So I follow the first suggestion: I reinstall krb5-server, and then I yum install openssl-devel and it works well.
After I solve the first problem, I use pip unsuccessfully and I follow the second suggestion: I recompile the python3.5 and the problem is solved.
First check wheather install openssl-develop
sudo apt-get install libssl-dev
or
yum install openssl-dev -y
Try another way to reinstall pip3 ,take Ubuntu for example
sudo apt-get install python3-setuptools
sudo easy_install3 pip
use setuptools to install pip may can solve the problem of dependency.
Try it on RHEL
sudo yum install -y python35-setuptools
sudo easy_install-3.5 pip

pip Not Working Python 2.7

I am having a problem with pip just now, when I try to install something like pip install readline then I get an error:
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/__init__.py", line 549, in load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2709, in load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2369, in load
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2375, in resolve
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 25, in <module>
from requests.compat import IncompleteRead
ImportError: cannot import name IncompleteRead
So I ran cat /usr/local/bin/pip which tells me pip==1.5.6. I tried to find a solution online regarding this and one solution told to cd /usr/local/lib/python2.7/site-packages && ls but for me I see that folder is also empty.
If upgrading pip doesn't work, you should try uninstalling it and reinstalling it. The error you're encountering is likely due to a mismatch in versions between pip and requests. First, I would remove pip and reinstall it from the source with python like this:
sudo apt-get remove python-pip
wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
From the Ubuntu launchpad site
Just check If You have installed python-setuptools rpm, If this is installed You can use easy_install pip on Redhat Based System.
I would comment this but due to low reputation I can't. Did you try upgrading pip?
pip install --upgrade pip
And then try to do that again.
If you are using Debian flavor OS (like Ubuntu) try this
apt-get remove python-pip
Then try to install the latest version by easy_install
easy_install pip

Categories