Unable to install Python pip or use easy_install - python

I am on OSX 10.10.3 with Python 2.7.6 as my main Python. I suddenly ran into trouble using pip, and tried to fix it. The solution proposed elsewhere on StackOverflow was to remove installations of pip and reinstall it either using their official installer or using easy_install.
Running the installation script (https://bootstrap.pypa.io/get-pip.py) gives:
Traceback (most recent call last):
File "pip.py", line 17767, in <module>
main()
File "pip.py", line 162, in main
bootstrap(tmpdir=tmpdir)
File "pip.py", line 82, in bootstrap
import pip
File "/tmp/tmpDnRtQK/pip.zip/pip/__init__.py", line 6, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/optparse.py", line 90, in <module>
from gettext import gettext
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/gettext.py", line 49, in <module>
import locale, copy, os, re, struct, sys
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 110, in <module>
#functools.wraps(_localeconv)
AttributeError: 'module' object has no attribute 'wraps'
and running "sudo easy_install pip" gives
Traceback (most recent call last):
File "/usr/bin/easy_install-2.7", line 7, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2793, in <module>
working_set.require(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 673, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 581, in resolve
requirements.extend(dist.requires(req.extras)[::-1])
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2323, in requires
dm = self._dep_map
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2374, in __getattr__
raise AttributeError(attr)
AttributeError: _dep_map
I am not really sure where to go next.
I am also in the situation that I can't import various modules, for example Flask, since I get the following error:
Traceback (most recent call last):
File "/Users/dawi/git/friends/run.py", line 2, in <module>
from application import app
File "/Users/dawi/git/friends/application/__init__.py", line 3, in <module>
from flask import Flask
File "/Library/Python/2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/__init__.py", line 17, in <module>
from werkzeug.exceptions import abort
File "/Library/Python/2.7/site-packages/Werkzeug-0.9.6-py2.7.egg/werkzeug/__init__.py", line 154, in <module>
__import__('werkzeug.exceptions')
File "/Library/Python/2.7/site-packages/Werkzeug-0.9.6-py2.7.egg/werkzeug/exceptions.py", line 71, in <module>
from werkzeug.wrappers import Response
File "/Library/Python/2.7/site-packages/Werkzeug-0.9.6-py2.7.egg/werkzeug/wrappers.py", line 23, in <module>
from functools import update_wrapper
ImportError: cannot import name update_wrapper

Related

AttributeError: module 'numpy.random' has no attribute 'mtrand'

After having installed the pyclustertend package with pip install pyclustertend, I now try to import it into Python:
from pyclustertent import ivat
However, I get the following error while doing so:
Traceback (most recent call last):
File "", line 1, in
from pyclustertend import ivat
File "C:\Users\Emil\AppData\Roaming\Python\Python38\site-packages\pyclustertend_init_.py", line 1, in
from .hopkins import hopkins # noqa: F401
File "C:\Users\Emil\AppData\Roaming\Python\Python38\site-packages\pyclustertend\hopkins.py", line 5, in <module>
from sklearn.neighbors import BallTree
File "C:\Users\Emil\Anaconda3\lib\site-packages\sklearn\__init__.py", line 82, in <module>
from .base import clone
File "C:\Users\Emil\Anaconda3\lib\site-packages\sklearn\base.py", line 17, in <module>
from .utils import _IS_32BIT
File "C:\Users\Emil\Anaconda3\lib\site-packages\sklearn\utils\__init__.py", line 29, in <module>
from .fixes import parse_version, threadpool_info
File "C:\Users\Emil\Anaconda3\lib\site-packages\sklearn\utils\fixes.py", line 47, in <module>
class loguniform(scipy.stats.reciprocal):
File "C:\Users\Emil\Anaconda3\lib\site-packages\scipy\stats\_distn_infrastructure.py", line 1601, in __init__
super(rv_continuous, self).__init__(seed)
File "C:\Users\Emil\Anaconda3\lib\site-packages\scipy\stats\_distn_infrastructure.py", line 588, in __init__
self._random_state = check_random_state(seed)
File "C:\Users\Emil\Anaconda3\lib\site-packages\scipy\_lib\_util.py", line 202, in check_random_state
return np.random.mtrand._rand
AttributeError: module 'numpy.random' has no attribute 'mtrand'
I suspected this has to do with the Numpy version. However, during the installation, it updated numpy to an older version:
Successfully uninstalled numpy-1.23.4
Successfully installed numpy-1.20.3 pyclustertend-1.8.2
What do I need to do to use this package?

Importing Pytest fails with "AttributeError: 'str' object has no attribute 'pattern'"

Trying to import pytest on Python 3.8 fails with the following error:
>>> import pytest
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Al\AppData\Local\Programs\Python\Python38\lib\site-packages\pytest\__init__.py", line 6, in <module>
from _pytest.assertion import register_assert_rewrite
File "C:\Users\Al\AppData\Local\Programs\Python\Python38\lib\site-packages\_pytest\assertion\__init__.py", line 7, in <module>
from _pytest.assertion import rewrite
File "C:\Users\Al\AppData\Local\Programs\Python\Python38\lib\site-packages\_pytest\assertion\rewrite.py", line 24, in <module>
from _pytest.assertion import util
File "C:\Users\Al\AppData\Local\Programs\Python\Python38\lib\site-packages\_pytest\assertion\util.py", line 14, in <module>
import _pytest._code
File "C:\Users\Al\AppData\Local\Programs\Python\Python38\lib\site-packages\_pytest\_code\__init__.py", line 2, in <module>
from .code import Code # noqa
File "C:\Users\Al\AppData\Local\Programs\Python\Python38\lib\site-packages\_pytest\_code\code.py", line 28, in <module>
import pluggy
File "C:\Users\Al\AppData\Local\Programs\Python\Python38\lib\site-packages\pluggy\__init__.py", line 16, in <module>
from .manager import PluginManager, PluginValidationError
File "C:\Users\Al\AppData\Local\Programs\Python\Python38\lib\site-packages\pluggy\manager.py", line 6, in <module>
import importlib_metadata
File "C:\Users\Al\AppData\Local\Programs\Python\Python38\lib\site-packages\importlib_metadata\__init__.py", line 478, in <module>
__version__ = version(__name__)
File "C:\Users\Al\AppData\Local\Programs\Python\Python38\lib\site-packages\importlib_metadata\__init__.py", line 445, in version
return distribution(package).version
File "C:\Users\Al\AppData\Local\Programs\Python\Python38\lib\site-packages\importlib_metadata\__init__.py", line 418, in distribution
return Distribution.from_name(package)
File "C:\Users\Al\AppData\Local\Programs\Python\Python38\lib\site-packages\importlib_metadata\__init__.py", line 179, in from_name
dists = resolver(name)
File "<frozen importlib._bootstrap_external>", line 1382, in find_distributions
File "C:\Users\Al\AppData\Local\Programs\Python\Python38\lib\importlib\metadata.py", line 379, in find_distributions
found = cls._search_paths(context.pattern, context.path)
AttributeError: 'str' object has no attribute 'pattern'
How do I fix this?
This was fixed on November 11, 2019 in this commit.
The solution is to update the pluggy dependency (the error happens in version 0.12.0) by running pip install -U pluggy (or pip3 install -U pluggy on macOS and Linux). Simply updating pytest is not enough to update its dependency.
After running pip, you should be able to import pytest without error.

Pip does not work on linux returning error:“from urllib3.packages.ordered_dict import OrderedDict ImportError: No module named ordered_dict”

I noticed i couldn't use pip anymore because of Import error whatever i do with pip, can't eve just run "pip" without getting:
cannot install urllib3 or setuputils using pip so i tryed downloading and then setup.py install them. Nothing worked
Traceback (most recent call last):
File "/usr/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 489,
in load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2843,
in load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2434,
in load
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2440,
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 22, in
<module>
import requests, six
File "/usr/lib/python2.7/dist-packages/requests/__init__.py", line 80, in
<module>
from . import utils
File "/usr/lib/python2.7/dist-packages/requests/utils.py", line 25, in
<module>
from .compat import parse_http_list as _parse_list_header
File "/usr/lib/python2.7/dist-packages/requests/compat.py", line 94, in
<module>
from urllib3.packages.ordered_dict import OrderedDict
ImportError: No module named ordered_dict
if i try ti pip install anything it gives me the error. Any suggestion?

Python not starting due to failed import site module google_auth-1.1.1

I am using Windows and was running Python 3.5.4 from the Anaconda distribution.
I was trying to install PyQt5 on my computer and I believe I ended up disrupting Python startup.
Now when I attempt to open python or ipython or pip, I get the following error:
Error processing line 1 of C:\Users\George\Anaconda3\lib\site-packages\google_auth-1.1.1-py2.7-nspkg.pth:
Failed to import the site module
Traceback (most recent call last):
File "C:\Users\George\Anaconda3\lib\site.py", line 167, in addpackage
exec(line)
File "<string>", line 1, in <module>
File "C:\Users\George\Anaconda3\lib\types.py", line 166, in <module>
import functools as _functools
File "C:\Users\George\Anaconda3\lib\functools.py", line 23, in <module>
from weakref import WeakKeyDictionary
File "C:\Users\George\Anaconda3\lib\weakref.py", line 12, in <module>
from _weakref import (
ImportError: cannot import name '_remove_dead_weakref'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\George\Anaconda3\lib\site.py", line 570, in <module>
main()
File "C:\Users\George\Anaconda3\lib\site.py", line 550, in main
known_paths = addsitepackages(known_paths)
File "C:\Users\George\Anaconda3\lib\site.py", line 327, in addsitepackages
addsitedir(sitedir, known_paths)
File "C:\Users\George\Anaconda3\lib\site.py", line 206, in addsitedir
addpackage(sitedir, name, known_paths)
File "C:\Users\George\Anaconda3\lib\site.py", line 177, in addpackage
import traceback
File "C:\Users\George\Anaconda3\lib\traceback.py", line 5, in <module>
import linecache
File "C:\Users\George\Anaconda3\lib\linecache.py", line 8, in <module>
import functools
File "C:\Users\George\Anaconda3\lib\functools.py", line 23, in <module>
from weakref import WeakKeyDictionary
File "C:\Users\George\Anaconda3\lib\weakref.py", line 12, in <module>
from _weakref import (
ImportError: cannot import name '_remove_dead_weakref'
I would prefer not to reinstall Anaconda as I had some files saved and other packages installed, yet don't quite know what to do.

python pip3 can't find threading module

I have both python 2.7.6 and 3.4.0 on my ubuntu 14.04. I want to be able to use both as some works were based on the older version. I started using 3 and want to get pip3 for package installation.
When I tried apt-get to get pip3, it failed. After a few SO searches, someone suggested installing it with aptitude which finally succeeded.
When I run pip3, i got this error,
Traceback (most recent call last):
File "/usr/lib/python3.4/queue.py", line 4, in <module>
import threading
ImportError: No module named 'threading'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
load_entry_point('pip==1.5.4', 'console_scripts', 'pip3')()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 351, in
load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2363,
in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2088, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 9, in <module>
from pip.log import logger
File "/usr/lib/python3/dist-packages/pip/log.py", line 8, in <module>
from pip import backwardcompat
File "/usr/lib/python3/dist-
packages/pip/backwardcompat/__init__.py", line 33, in <module>
from queue import Queue, Empty
File "/usr/lib/python3.4/queue.py", line 6, in <module>
import dummy_threading as threading
File "/usr/lib/python3.4/dummy_threading.py", line 45, in <module>
import threading
ImportError: No module named 'threading'

Categories

Resources