Issue with pip - Traceback error - Messed up installation? [duplicate] - python

This question already has answers here:
The 'pip==7.1.0' distribution was not found and is required by the application
(11 answers)
Closed 1 year ago.
I am having some issues running pip on my iTerm on my Mac (Big Sur 11.4)
I have already tried a couple things.
a. removed the Python framework from /Library/Frameworks (in an effort to clean remove python 3)
b. removed the Python apps from Applications
(that said, python3 still runs the interpreter)
Here is the error message, below.
Any input would be appreciated
Thank you
File "/usr/local/bin/pip", line 6, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 3241, in <module>
#_call_aside
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 3225, in _call_aside
f(*args, **kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 3254, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 585, in _build_master
return cls._build_from_requirements(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 598, in _build_from_requirements
dists = ws.resolve(reqs, Environment())
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 786, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'pip==20.0.2' distribution was not found and is required by the application```

My guess is that you have more than one soft links of pip in your default directory. Maybe try checking it by where pip3 and rm the soft links of older versions.

Related

Pip TypeError on Macbook M1 [duplicate]

This question already has answers here:
Upgrading pip fails with syntax error caused by sys.stderr.write(f"ERROR: {exc}")
(12 answers)
Closed 1 year ago.
so i tried to install pip using homebrew, and then i got this error
Traceback (most recent call last):
File "/usr/local/bin/pip", line 11, in <module>
load_entry_point('pip==21.0.1', 'console_scripts', 'pip')()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 489, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2843, in load_entry_point
return ep.load()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2434, in load
return self.resolve()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2440, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/Library/Python/2.7/site-packages/pip-21.0.1-py2.7.egg/pip/_internal/cli/main.py", line 60
sys.stderr.write(f"ERROR: {exc}")
I do not know what to do or have any idea why, but is there a way to uninstall it??
M1 chip isn't your problem. Pip no longer supports Python2 and pip comes with Python3, so brew install pip would be incorrect installation, anyway

Error pyfits install : Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-zMkboe/pyfits/

Context
I have a problem with healpy which gives me :
AttributeError: 'module' object has no attribute 'read_map'
After checking, I was able to see that the 'read_map' function of healpy was given by healpy.fitsfunc, and when I tried to import specifically this module :
import healpy.fitsfunc
I obtained :
Traceback (most recent call last):
File "<ipython-input-1-1ab0f97bea12>", line 1, in <module>
import healpy.fitsfunc
File "/home/magdy/Documents/StageM1/cosmicvoids-vide_public-82492565081e/ext_build/python/lib/python2.7/site-packages/healpy/fitsfunc.py", line 23, in <module>
import pyfits as pf
ImportError: No module named pyfits
Which is the reason I try to install pyfits.
Error
When I try
pip install pyfits
I obtain :
Collecting pyfits
Using cached https://files.pythonhosted.org/packages/c0/5d/ffae283cea526bce7c1154e7309a040a3e8c02e973b2360bcfc8f30134ef/pyfits-3.5.tar.gz
Complete output from command python setup.py egg_info:
Installed /tmp/easy_install-HZAa1H/stsci.distutils-0.3.7/.eggs/d2to1-0.2.12.post1-py2.7.egg
/usr/local/lib/python2.7/dist-packages/setuptools/dist.py:47: DistDeprecationWarning: Do not call this function
warnings.warn("Do not call this function", DistDeprecationWarning)
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-QgcwJz/pyfits/setup.py", line 14, in <module>
zip_safe=False
File "/usr/local/lib/python2.7/dist-packages/setuptools/__init__.py", line 144, in setup
_install_setup_requires(attrs)
File "/usr/local/lib/python2.7/dist-packages/setuptools/__init__.py", line 139, in _install_setup_requires
dist.fetch_build_eggs(dist.setup_requires)
File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 724, in fetch_build_eggs
replace_conflicting=True,
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 782, in resolve
replace_conflicting=replace_conflicting
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1065, in best_match
return self.obtain(req, installer)
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1077, in obtain
return installer(requirement)
File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 791, in fetch_build_egg
return cmd.easy_install(req)
File "/usr/local/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 679, in easy_install
return self.install_item(spec, dist.location, tmpdir, deps)
File "/usr/local/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 705, in install_item
dists = self.install_eggs(spec, download, tmpdir)
File "/usr/local/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 890, in install_eggs
return self.build_and_install(setup_script, setup_base)
File "/usr/local/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1158, in build_and_install
self.run_setup(setup_script, setup_base, args)
File "/usr/local/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1146, in run_setup
raise DistutilsError("Setup script exited with %s" % (v.args[0],))
distutils.errors.DistutilsError: Setup script exited with error in setup command: Error parsing /tmp/easy_install-HZAa1H/stsci.distutils-0.3.7/setup.cfg: TypeError: super() argument 1 must be type, not None
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-QgcwJz/pyfits/
I have already tried :
pip install --upgrade setuptools
And a lot of other solutions, but none of them seems to work or apply to my case.
I have also tried to download directly pyfits3.5 and install it with
pip install .
but this gave me the same error.
System
Ubuntu 18.04.2 LTS (dual boot)
pip 19.0.3 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)
Python 2.7.15rc1
Thank you for helping me.

"sre_constants.error: nothing to repeat" error every time trying to install using pip

I just installed Python 2.7.5 on my Windows 10 machine and I also got pip installed through setuptools. However whenever I try to install something using pip e.g. pip install numpy, I get this error message:
Traceback (most recent call last):
File "C:\Python27\Scripts\pip-script.py", line 8, in <module>
load_entry_point('pip==9.0.1', 'console_scripts', 'pip')()
File "C:\Python27\lib\site-packages\pkg_resources.py", line 318, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "C:\Python27\lib\site-packages\pkg_resources.py", line 2221, in load_entry_point
return ep.load()
File "C:\Python27\lib\site-packages\pkg_resources.py", line 1954, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "C:\Python27\lib\site-packages\pip-9.0.1-py2.7.egg\pip\__init__.py", line 26, in <module>
from pip.utils import get_installed_distributions, get_prog
File "C:\Python27\lib\site-packages\pip-9.0.1-py2.7.egg\pip\utils\__init__.py", line 27, in <module>
from pip._vendor import pkg_resources
File "C:\Python27\lib\site-packages\pip-9.0.1-py2.7.egg\pip\_vendor\pkg_resources\__init__.py", line 73, in <module>
__import__('pip._vendor.packaging.specifiers')
File "C:\Python27\lib\site-packages\pip-9.0.1-py2.7.egg\pip\_vendor\packaging\specifiers.py", line 275, in <module>
class Specifier(_IndividualSpecifier):
File "C:\Python27\lib\site-packages\pip-9.0.1-py2.7.egg\pip\_vendor\packaging\specifiers.py", line 373, in Specifier
r"^\s*" + _regex_str + r"\s*$", re.VERBOSE | re.IGNORECASE)
File "C:\Python27\Lib\re.py", line 190, in compile
return _compile(pattern, flags)
File "C:\Python27\Lib\re.py", line 242, in _compile
raise error, v # invalid expression
sre_constants.error: nothing to repeat
Since I'm pretty new to Python, I don't really understand what this error means. Any workaround?
I had a similar issue with a library that is using regular expressions (with the re.compile() function). I solved this issue installing the last version available 2.7.13 (I run a Windows 7).
Before I had the 2.7.6 version. I updated it installing the new version with the .msi installer, available in the Python web page.

Trying to run Scrapy

I am trying to run Scrapy and encountering the following error.
It seems that Scrapy can't find TheTwisted 10.0.0 - I've downloaded it but don't know where to place the folder. Thanks!
Traceback (most recent call last):
File "/usr/local/bin/scrapy", line 5, in
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/init.py", line 3095, in
#_call_aside
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/init.py", line 3081, in _call_aside
f(*args, **kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/init.py", line 3108, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/init.py", line 658, in _build_master
ws.require(requires)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/init.py", line 959, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/init.py", line 846, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'Twisted>=10.0.0' distribution was not found and is required by Scrapy
If using Linux, install Twisted by running pip install Twisted in terminal.
If Windows, the Twisted docs recommend pip install Twisted[windows_platform].
In both cases if you're using a virtual environment (recommended) make sure to install it inside the venv.

Error when creating Database Tables - CKAN

i'm trying to install CKAN 2.5.2 on Centos 6.8
When i run paster db init -c /etc/ckan/default/development.ini
i get error
Traceback (most recent call last):
File "/usr/lib/ckan/default/bin/paster", line 9, in <module>
load_entry_point('PasteScript==2.0.2', 'console_scripts', 'paster')()
File "/usr/lib/ckan/default/lib/python2.6/site-packages/paste/script/command.py", line 102, in run
invoke(command, command_name, options, args[1:])
File "/usr/lib/ckan/default/lib/python2.6/site-packages/paste/script/command.py", line 141, in invoke
exit_code = runner.run(args)
File "/usr/lib/ckan/default/lib/python2.6/site-packages/paste/script/command.py", line 236, in run
result = self.command()
File "/usr/lib/ckan/default/src/ckan/ckan/lib/cli.py", line 205, in command
self._load_config(cmd!='upgrade')
File "/usr/lib/ckan/default/src/ckan/ckan/lib/cli.py", line 142, in _load_config
conf = self._get_config()
File "/usr/lib/ckan/default/src/ckan/ckan/lib/cli.py", line 139, in _get_config
return appconfig('config:' + self.filename)
File "/usr/lib/ckan/default/lib/python2.6/site-packages/paste/deploy/loadwsgi.py", line 261, in appconfig
global_conf=global_conf)
File "/usr/lib/ckan/default/lib/python2.6/site-packages/paste/deploy/loadwsgi.py", line 296, in loadcontext
global_conf=global_conf)
File "/usr/lib/ckan/default/lib/python2.6/site-packages/paste/deploy/loadwsgi.py", line 320, in _loadconfig
return loader.get_context(object_type, name, global_conf)
File "/usr/lib/ckan/default/lib/python2.6/site-packages/paste/deploy/loadwsgi.py", line 454, in get_context
section)
File "/usr/lib/ckan/default/lib/python2.6/site-packages/paste/deploy/loadwsgi.py", line 476, in _context_from_use
object_type, name=use, global_conf=global_conf)
File "/usr/lib/ckan/default/lib/python2.6/site-packages/paste/deploy/loadwsgi.py", line 406, in get_context
global_conf=global_conf)
File "/usr/lib/ckan/default/lib/python2.6/site-packages/paste/deploy/loadwsgi.py", line 296, in loadcontext
global_conf=global_conf)
File "/usr/lib/ckan/default/lib/python2.6/site-packages/paste/deploy/loadwsgi.py", line 328, in _loadegg
return loader.get_context(object_type, name, global_conf)
File "/usr/lib/ckan/default/lib/python2.6/site-packages/paste/deploy/loadwsgi.py", line 620, in get_context
object_type, name=name)
File "/usr/lib/ckan/default/lib/python2.6/site-packages/paste/deploy/loadwsgi.py", line 646, in find_egg_entry_point
possible.append((entry.load(), protocol, entry.name))
File "/usr/lib/ckan/default/lib/python2.6/site-packages/pkg_resources/__init__.py", line 2229, in load
return self.resolve()
File "/usr/lib/ckan/default/lib/python2.6/site-packages/pkg_resources/__init__.py", line 2235, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/lib/ckan/default/src/ckan/ckan/config/middleware.py", line 28, in <module>
from ckan.config.environment import load_environment
File "/usr/lib/ckan/default/src/ckan/ckan/config/environment.py", line 18, in <module>
import ckan.lib.helpers as h
File "/usr/lib/ckan/default/src/ckan/ckan/lib/helpers.py", line 30, in <module>
from bleach import clean as clean_html
File "/usr/lib/ckan/default/lib/python2.6/site-packages/bleach/__init__.py", line 8, in <module>
from html5lib.sanitizer import HTMLSanitizer
ImportError: No module named sanitizer
I was following wiki instructions
I'm stuck on this step and don't know how to proceed.
Module html5lib is imported and updated to latest version. Paster script is executed in virtualenv under root account.
Also i'm running all of this in python2.6 since that is default on Centos.
Some additional information
when i run python and import html5lib and then help(html5lib) i get this
>>> import html5lib
>>> help(html5lib)
Help on package html5lib:
NAME
html5lib
FILE
/usr/lib/python2.6/site-packages/html5lib/__init__.py
DESCRIPTION
HTML parsing library based on the WHATWG "HTML5"
specification. The parser is designed to be compatible with existing
HTML found in the wild and implements well-defined error recovery that
is largely compatible with modern desktop web browsers.
Example usage:
import html5lib
f = open("my_document.html")
tree = html5lib.parse(f)
PACKAGE CONTENTS
_ihatexml
_inputstream
_tokenizer
_trie (package)
_utils
constants
filters (package)
html5parser
serializer
treeadapters (package)
treebuilders (package)
treewalkers (package)
CLASSES
__builtin__.object
html5lib.html5parser.HTMLParser
class HTMLParser(__builtin__.object)
| HTML parser. Generates a tree structure from a stream of (possibly
| malformed) HTML
|
| Methods defined here:
:
There is no sanitizer here. Do i need to use specific version of html5lib?
Can anyone help?
It looks like you have 2 copies of html5lib installed. When you did help(html5lib) it is showing a copy that is installed in your user's python directory (/usr/lib/python2.6/site-packages/) not the virtualenv that you have ckan (and bleach) installed (/usr/lib/ckan/default/lib/python2.6/site-packages/). So get rid of the former to avoid confusion.
Yes I think you have the wrong version of html5lib, since sanitizer is listed in the package contents when I do help.
This is the correct version (at the time of writing - in future check what is in requirements.txt):
$ pip freeze | grep html5lib
html5lib==0.9999999

Categories

Resources