Python Scrapy will not run showing pkg_resources.DistributionNotFound: service-identity - python

Scrapy will not run on my Ubuntu 14.04 giving the error:
Traceback (most recent call last):
File "/usr/bin/scrapy", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2749, in <module>
working_set = WorkingSet._build_master()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 444, in _build_master
ws.require(__requires__)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 725, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 628, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: service-identity
Timeline: I had Python 2.7.6 installed which came with Ubuntu 14.04. I upgraded to 2.7.9 which is currently my python -V. I started by downloaded scrapy from the website (scrapy.org) following their Ubuntu instructions, and I got the error code above when attempting to use scrapy. Then I went through every imaginable stackoverflow for pip being broken, scrapy being broken but no good.
pip upgrade did not work:
pip broke. how to fix DistributionNotFound error?
This guy had almost the same error but no response:
Python(Scrapy) unpredictable mistake with "import load_entry_point"
He pointed to: Python & Scrapy: Issue with Scrapy version
I uninstalled all scrapy and reinstalled with pip (it was installing version Scrapy-1.0.3) and it initially failed but I upgraded some libraries (libffi & lxml) and the install worked with a sudo run. Same error remained when running scrappy.
Any chance anyone knows whats going on? Thanks

make sure you have installed the service identity package. you can install it by:
sudo pip install service-identity

Related

how to fix "ImportError: cannot import name 'FormatControl'" for pip?

For some reason I can't install anything with pip/pip3 lately. For example, when I try to install mendeley using the command "pip install mendeley", the following error message appears:
Traceback (most recent call last):
File "/Users/u1790509/anaconda3/bin/pip", line 11, in <module>
load_entry_point('pip==10.0.1', 'console_scripts', 'pip')()
File "/Users/u1790509/anaconda3/lib/python3.6/site-packages/pkg_resources/__init__.py", line 480, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/Users/u1790509/anaconda3/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2691, in load_entry_point
return ep.load()
File "/Users/u1790509/anaconda3/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2322, in load
return self.resolve()
File "/Users/u1790509/anaconda3/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2328, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/Users/u1790509/anaconda3/lib/python3.6/site-packages/pip/_internal/__init__.py", line 42, in <module>
from pip._internal import cmdoptions
File "/Users/u1790509/anaconda3/lib/python3.6/site-packages/pip/_internal/cmdoptions.py", line 16, in <module>
from pip._internal.index import (
ImportError: cannot import name 'FormatControl'
The same error appears whenever I attempt to install packages using pip. Does anyone have any suggestion for fixing it?
thanks,
Stephen
I was having this issue on systems running older versions of Anaconda and Python. Downgrading pip as per this answer and then upgrading it worked for me.
I ran:
conda install pip==9.0.3
pip install --upgrade pip
Then I was able to install the package I wanted to via pip install ....
I'm not sure what's going on behind the scenes since after downgrading from 10.x to 9.0.3, I still got:
Successfully uninstalled pip-20.0.2
Successfully installed pip-20.3.4
Probably a result of mixing Anaconda and pip for package management, but works for now for legacy purposes.

Python "pip install " is failing with AttributeError: 'module' object has no attribute 'SSL_ST_INIT'

$ sudo pip install --upgrade pyOpenSSL
Traceback (most recent call last):
File "/usr/local/bin/pip", line 9, in <module>
load_entry_point('pip==8.1.1', '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/local/lib/python2.7/dist-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/lib/python2.7/dist-packages/pip-8.1.1-
py2.7.egg/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/usr/local/lib/python2.7/dist-packages/pip-8.1.1-
py2.7.egg/pip/download.py", line 39, in <module>
from pip._vendor import requests, six
File "/usr/local/lib/python2.7/dist-packages/pip-8.1.1-
py2.7.egg/pip/_vendor/requests/__init__.py", line 53, in <module>
from .packages.urllib3.contrib import pyopenssl
File "/usr/local/lib/python2.7/dist-packages/pip-8.1.1-
py2.7.egg/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/SSL.py", line 118, in
<module>
SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: 'module' object has no attribute 'SSL_ST_INIT'
I am unable to Uninstall " pip uninstall pyopenssl "
Using pip gets me this error.
Thanks in advance.
Additional Details:
I am using
Distributor ID: Ubuntu
Description: Ubuntu 15.10
Release: 15.10
Codename: wily
I ran into this issue as well. The solution proposed to run pip doesn't work because pip is broken too! I found this solved it for me:
sudo python -m easy_install --upgrade pyOpenSSL
This installed version 17.3.0 which was an upgrade to the (stock python-openssl on xenial) version ?0.15.1?. Note the massive change in version it could be they dropped the leading 0. in later versions.
Anyway, after that, pip and ansible started to work again.
I did the following which seemed to fix the error, not sure if it's the correct way, but it did fix the error on my machine:
I first backed up the directories below, recommend you do same.
rm -rf /usr/lib/python2.7/dist-packages/OpenSSL
rm -rf /usr/lib/python2.7/dist-packages/pyOpenSSL-0.15.1.egg-info
sudo pip install pyopenssl
I couldn't uninstall it because every time I ran pip I got the same error you did: 'module' object has no attribute 'SSL_ST_INIT'.
After the above my pip now works and more importantly my ansible now works (which was broken by my previous updates).
Not sure if it will work on your system, and removing things out of band, like I did, is risky at best, so as a warning, I would say, your mileage may vary with my kludgy fix, use caution!
Below method worked for me, I am using Ubuntu 20.04 and wanted to install Objection for Runtime manipulation and dynamic analysis of iOS apps.
Short Background:
I noticed that when I fired pip3 install objection in terminal it gave me same error as you but the directory path was little bit different.
In my case it was related to python3.8, so I did following things
Solution:
rm -rf /home/smshrimant/.local/lib/python3.8/site-packages/OpenSSL/
sudo rm -rf /usr/local/lib/python3.8/dist-packages/OpenSSL/
Upgrading pyOpenSSL to 16.2.0 fixes it.
pip uninstall pyOpenSSL
pip install pyOpenSSL==16.2.0
There is an issue with version compatibility.

Error after installing EB CLI 3.x

I am trying to install the elastic beanstalk CLI on an EC2 instance (running AMI) using these instructions:
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-getting-started.html
I have python 2.7.9 installed, pip and eb. However, when I try to run eb I get the error below. It looks like it is still using python 2.6. How do you fix that?
Thanks!
Traceback (most recent call last):
File "/usr/bin/eb", line 9, in <module>
load_entry_point('awsebcli==3.0.10', 'console_scripts', 'eb')()
File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 473, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 2568, in load_entry_point
return ep.load()
File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 2259, in load
['__name__'])
File "/usr/lib/python2.6/site-packages/ebcli/core/ebcore.py", line 23, in <module>
from ..controllers.initialize import InitController
File "/usr/lib/python2.6/site-packages/ebcli/controllers/initialize.py", line 16, in <module>
from ..core.abstractcontroller import AbstractBaseController
File "/usr/lib/python2.6/site-packages/ebcli/core/abstractcontroller.py", line 21, in <module>
from ..core import io, fileoperations, operations
File "/usr/lib/python2.6/site-packages/ebcli/core/operations.py", line 762
vars = {n['OptionName']: n['Value'] for n in settings
^
SyntaxError: invalid syntax
Pip is probably set up with Python 2.6 instead of python 2.7.
pip --version
You can reinstall pip with Python 2.7, then reinstall 2.6
pip uninstall awsebcli
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py
pip install awsebcli
I had the same problem, the fix for me was actually to upgrade to latest Beanstalk stack ( eb upgrade ). Note there are downtime etc. So investigate if you can run the latest stack before upgrading.
The "smartest" solution for me was to install python-dev tools
sudo apt install python-dev
found here:
http://ericbenson.azurewebsites.net/deployment-on-aws-elastic-beanstalk-for-ubuntu/

Trouble with pip in Mountain Lion

I'm having trouble running pip in Mountain Lion. I was under the impression that it should come preinstalled with Python (which is working), but trying to run any pip command just presents me with the following:
-bash: pip: command not found
I've tried
sudo easy_install pip
but get the following error:
Traceback (most recent call last):
File "/usr/bin/easy_install-2.7", line 10, in
load_entry_point('setuptools==0.6c12dev-r88846', 'console_scripts', 'easy_install')()
File "build/bdist.macosx-10.6-x86_64/egg/pkg_resources.py", line 347, in load_entry_point
File "build/bdist.macosx-10.6-x86_64/egg/pkg_resources.py", line 2516, in load_entry_point
ImportError: Entry point ('console_scripts', 'easy_install') not found
I've also tried using get-pip.py, as suggested at http://www.pip-installer.org/en/latest/installing.html, but this gives me a whole slew of errors.
Installing from source seems to work, but pip is still not found
I have a feeling there might be something wrong with my path:
~/.bin/:/usr/local/share/python:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
Any help would be greatly appreciated.
Thank you

python nosetests won't work

I was learning Python from 'learning python the hard way' and I was stuck at exercise 46 (http://learnpythonthehardway.org/book/ex46.html).
I installed pip and then the nose package and whenever i run nosetest now as in the example it doesn't work. This is the error I get:
Traceback (most recent call last):
File "/usr/local/bin/nosetests", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2807, in <module>
parse_requirements(__requires__), Environment()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 594, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: nose==1.3.0
I googled about this but couldn't find an answer.
I am on a Lubuntu 13.04 desktop.
You need to install a version of nose equal to 1.3.0 (maybe the nose version that you installed is not 1.3.0?)
You can find out what version of nose you have installed with
>>> import nose
>>> nose.__version__
'1.3.0'
Using pip this is as simple as (if you already have nose installed then you will want to use the --upgrade flag)
pip install --upgrade nose==1.3.0
or even direct from the website
pip install -Iv https://pypi.python.org/packages/source/n/nose/nose-1.3.0.tar.gz#md5=95d6d32b9d6b029c3c65674bd9e7eabe

Categories

Resources