Error when using pip to install - python

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

Related

Screwed up pip, getting "ImportError: Entry point ('console_scripts', 'pip') not found"

Somehow I screwed up my install of pip. I can't install anything using pip or even just get the version. When I try getting the version I get the following error:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 8, in <module>
load_entry_point('pip==1.3.1', 'console_scripts', 'pip')()
File "/Library/Python/2.7/site-packages/pkg_resources.py", line 343, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/Library/Python/2.7/site-packages/pkg_resources.py", line 2353, in load_entry_point
raise ImportError("Entry point %r not found" % ((group,name),))
ImportError: Entry point ('console_scripts', 'pip') not found
I found a Stack Overflow post that said I should re-install pip using: python -m pip install --upgrade --force-reinstall pip but when I do that I get:
/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: No module named pip
And of course trying to reinstall python using: brew install python gets me:
==> Installing dependencies for python: readline, sqlite, gdbm, makedepend, openssl
==> Installing python dependency: readline
==> Downloading http://ftpmirror.gnu.org/readline/readline-6.3.tar.gz
Already downloaded: /Library/Caches/Homebrew/readline-6.3.8.tar.gz
==> Downloading https://gist.githubusercontent.com/jacknagel/d886531fb6623b60b2af/raw/746fc543e56bc37a26ccf05d2946a45176b0894e/readline-6.3.8.diff
##O=# #
curl: (22) The requested URL returned error: 404 Not Found
Error: Failed to download resource "readline--patch"
Download failed: https://gist.githubusercontent.com/jacknagel/d886531fb6623b60b2af/raw/746fc543e56bc37a26ccf05d2946a45176b0894e/readline-6.3.8.diff
I found another Stack Overflow post that said to use the get-pip.py file but doing that
throws the following:
Traceback (most recent call last):
File "get-pip.py", line 23484, in <module>
main()
File "get-pip.py", line 198, in main
bootstrap(tmpdir=tmpdir)
File "get-pip.py", line 83, in bootstrap
from pip._internal.commands.install import InstallCommand
File "/tmp/tmpH6zFs7/pip.zip/pip/_internal/commands/install.py", line 24, in <module>
File "/tmp/tmpH6zFs7/pip.zip/pip/_internal/cli/req_command.py", line 16, in <module>
File "/tmp/tmpH6zFs7/pip.zip/pip/_internal/index/package_finder.py", line 21, in <module>
File "/tmp/tmpH6zFs7/pip.zip/pip/_internal/index/collector.py", line 14, in <module>
File "/tmp/tmpH6zFs7/pip.zip/pip/_vendor/requests/__init__.py", line 97, in <module>
File "/tmp/tmpH6zFs7/pip.zip/pip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import crypto, SSL
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/OpenSSL/crypto.py", line 12, in <module>
from cryptography import x509
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/cryptography/x509/__init__.py", line 7, in <module>
from cryptography.x509 import certificate_transparency
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/cryptography/x509/certificate_transparency.py", line 22, in <module>
#six.add_metaclass(abc.ABCMeta)
AttributeError: 'module' object has no attribute 'add_metaclass'
So as you can see I am bit stuck. I'm sure it is something simple that I am missing but I can't figure our what it is. Does anyone know how I can get my pip back & working? At this point I might also be interested in nuking my Python 2.7 install & starting again from scratch if that is possible. Thanks in advance.
__Mikk

Pip error -> ImportError: No module named helpers

When I'm trying to install any package using pip it gives an error. It shows "ImportError: No module named helpers". I tried installing the helpers module using pip but the same error occurred. I'm pasting the output of the error message. Operating System: Arch Linux.
pip2 install requests
Error:
Traceback (most recent call last):
File "/usr/bin/pip2", line 11, in <module>
load_entry_point('pip==18.1', 'console_scripts', 'pip')()
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 489, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2793, in load_entry_point
return ep.load()
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2411, in load
return self.resolve()
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2417, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/lib/python2.7/site-packages/pip/_internal/__init__.py", line 40, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/usr/lib/python2.7/site-packages/pip/_internal/cli/autocompletion.py", line 8, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/usr/lib/python2.7/site-packages/pip/_internal/cli/main_parser.py", line 8, in <module>
from pip._internal.cli import cmdoptions
File "/usr/lib/python2.7/site-packages/pip/_internal/cli/cmdoptions.py", line 22, in <module>
from pip._internal.utils.ui import BAR_TYPES
File "/usr/lib/python2.7/site-packages/pip/_internal/utils/ui.py", line 15, in <module>
from pip._vendor.progress.helpers import HIDE_CURSOR, SHOW_CURSOR, WritelnMixin
ImportError: No module named helpers
Thanks for everyone's help. I found out the solution. When I upgraded to python 3.7 pip was broken.
Executing these commands solved the issue.
rm -rf /usr/lib/python3.7/site-packages
python3.7 -m ensurepip
pip install --upgrade pip
Same can be used with Python2 as well, just replacing 3.7 with 2.7 and pip with pip2.

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

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.

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.

Python version conflicts and pip3

It is a tough situation I am dealing with. Here is short version of my problem:
I am working on Ubuntu 12.04
I would like to install Python 3.5.x with openCV library. I would also like to use pip3 for managing package installation of python.
Here is how the version of my pythons looks like
$ python --version
Python 2.7.3
$ python3 --version
Python 3.5.2
So far it looks I have achieved my goal.
When I use virtualenv to manage python3 libraries:
virtualenv -p /usr/bin/python3 py3env
source py3env/bin/activate
I see the version of my python as follows:
(py3env)yxxxxa#yxxxxa-Precision-M4800:~$ python3 --version
Python 3.2.3
I seems there is another version of python in my machine 3.2.3 messing up with the version 3.5.2 that I have installed. This is my first problem.
The second related problem is that I am unable to install pip 3. There is this error I receive due to the same python version conflict:
$ pip
/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/_vendor /pkg_resources/__init__.py:80: UserWarning: Support for Python 3.0-3.2 has been dropped. Future versions will fail here.
warnings.warn(msg)
Traceback (most recent call last):
File "/usr/local/bin/pip", line 9, in <module>
load_entry_point('pip==8.1.2', 'console_scripts', 'pip')()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 337, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2280, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 1990, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/__init__.py", line 16, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/download.py", line 36, in <module>
from pip.utils.ui import DownloadProgressBar, DownloadProgressSpinner
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/utils/ui.py", line 15, in <module>
from pip._vendor.progress.bar import Bar, IncrementalBar
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/_vendor/progress/bar.py", line 48
empty_fill = u'∙'
^
SyntaxError: invalid syntax
yasharatena#yasharatena-Precision-M4800:~$ pip3
/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/_vendor/pkg_resources/__init__.py:80: UserWarning: Support for Python 3.0-3.2 has been dropped. Future versions will fail here.
warnings.warn(msg)
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 9, in <module>
load_entry_point('pip==8.1.2', 'console_scripts', 'pip3')()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 337, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2280, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 1990, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/__init__.py", line 16, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/download.py", line 36, in <module>
from pip.utils.ui import DownloadProgressBar, DownloadProgressSpinner
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/utils/ui.py", line 15, in <module>
from pip._vendor.progress.bar import Bar, IncrementalBar
File "/usr/local/lib/python3.2/dist-packages/pip-8.1.2-py3.2.egg/pip/_vendor/progress/bar.py", line 48
empty_fill = u'∙'
^
SyntaxError: invalid syntax
What are your expert opinions about the stated problem? Any cool idea to handle this? Thanks alot in advance
This solved my first problem. Now the second problem aslo remains, how
can I install pip3 under python 3.5.2 (preferably using viretualenv) ?
Here is answer:
python3 -m virtualenv py3env
source py3env/bin/activate
Python 3.5 should have pip by default, also after above commands You can use pip:)
For example :
python -m pip install requests
EDIT:
Here You could find very good explainations if You still need install pip after create virtualenv.

Categories