python pip3 can't find threading module - python

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'

Related

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?

ImportError: No module named 'requests.packages.urllib3'

I am testing an application and I am getting the above error "ImportError: No module named 'requests.packages.urllib3'" Below are the details.
[root#lab ~]# python /opt/test/panda_API.py
Traceback (most recent call last):
File "/opt/test/panda_API.py", line 8, in <module>
import requests
File "/usr/lib/python2.6/site-packages/requests/__init__.py", line 58, in <module>
from . import utils
File "/usr/lib/python2.6/site-packages/requests/utils.py", line 32, in <module>
from .exceptions import InvalidURL
File "/usr/lib/python2.6/site-packages/requests/exceptions.py", line 10, in <module>
from .packages.urllib3.exceptions import HTTPError as BaseHTTPError
File "/usr/lib/python2.6/site-packages/requests/packages/__init__.py", line 99, in load_module
raise ImportError("No module named '%s'" % (name,))
ImportError: No module named 'requests.packages.urllib3'
In a bid to resolve that, I try to pip install requests. Then the following error pops up.
[root#lab ~]# pip install requests
Traceback (most recent call last):
File "/usr/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 954, in <module>
class Environment:
File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 958, in Environment
self, search_path=None, platform=get_supported_platform(),
File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 188, in get_supported_platform
plat = get_build_platform()
File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 388, in get_build_platform
from sysconfig import get_platform
ImportError: No module named sysconfig
I have searched for solution here on stack overflow and other platforms, the closest is the one in this page on stack overflow. (ImportError: No module named sysconfig--can't get pip working).
I have tried the steps proposed in the above link, yet the same error "ImportError: No module named sysconfig", keeps repeating.
Running "pip -V", generated the same error.
Running the recommended command to check the version of setuptools, generated the following error --------
[root#lab pkg_resources]# python2.6 -c "import setuptools; print(setuptools.__version__)"
`Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python2.6/site-packages/setuptools/__init__.py", line 14, in <module >
import setuptools.version
File "/usr/lib/python2.6/site-packages/setuptools/version.py", line 1, in <module>
import pkg_resources
File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 954, in <mo dule>
class Environment:
File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 958, in Env ironment
self, search_path=None, platform=get_supported_platform(),
File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 188, in get _supported_platform
plat = get_build_platform()
File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 388, in get _build_platform
from sysconfig import get_platform
ImportError: No module named sysconfig
I have checked /usr/lib/python2.6/site-packages, and I do not have pkg_resources.py. Instead, what I have is the directory pkg_resources.
It appears that I have a more complicated case. Please I need help please!
Notes:
OS: CentOS release 6.10 (Final), and Python Version: Python 2.6.6
firstly run this command,
pip install requests urllib3 pyOpenSSL --force --upgrade
then install pyOpenSSL version 16.2.0 and run this command
pip install pyOpenSSL==16.2.0
Update your distribution packages! Python 2.6 is dead.

Neither Anaconda Navigator or Jupyter Notebook will open

I recently installed Anaconda on my Mac (running OS X 10.8.5), and I'm having several errors:
(1) When I try to open the Anaconda Navigator from the anaconda3 folder, the icon displays on my Dock then quickly disappears.
(2) When I use the command anaconda-navigator in terminal, it displays this error message:
Traceback (most recent call last):
File "/Users/jakesansom/anaconda3/lib/python3.6/site-packages/qtpy/__init__.py", line 166, in <module>
from PySide import __version__ as PYSIDE_VERSION # analysis:ignore
ModuleNotFoundError: No module named 'PySide'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/jakesansom/anaconda3/bin/anaconda-navigator", line 7, in <module>
from anaconda_navigator.app.main import main
File "/Users/jakesansom/anaconda3/lib/python3.6/site-packages/anaconda_navigator/app/main.py", line 22, in <module>
from anaconda_navigator.utils.conda import is_conda_available
File "/Users/jakesansom/anaconda3/lib/python3.6/site-packages/anaconda_navigator/utils/__init__.py", line 15, in <module>
from qtpy.QtGui import QIcon
File "/Users/jakesansom/anaconda3/lib/python3.6/site-packages/qtpy/__init__.py", line 172, in <module>
raise PythonQtError('No Qt bindings could be found')
qtpy.PythonQtError: No Qt bindings could be found
(3) When I use the command jupyter notebook in terminal, it displays this error message:
Traceback (most recent call last):
File "/Users/jakesansom/anaconda3/bin/jupyter-notebook", line 7, in <module>
from notebook.notebookapp import main
File "/Users/jakesansom/anaconda3/lib/python3.6/site-packages/notebook/notebookapp.py", line 45, in <module>
from zmq.eventloop import ioloop
File "/Users/jakesansom/anaconda3/lib/python3.6/site-packages/zmq/__init__.py", line 47, in <module>
from zmq import backend
File "/Users/jakesansom/anaconda3/lib/python3.6/site-packages/zmq/backend/__init__.py", line 40, in <module>
reraise(*exc_info)
File "/Users/jakesansom/anaconda3/lib/python3.6/site-packages/zmq/utils/sixcerpt.py", line 34, in reraise
raise value
File "/Users/jakesansom/anaconda3/lib/python3.6/site-packages/zmq/backend/__init__.py", line 27, in <module>
_ns = select_backend(first)
File "/Users/jakesansom/anaconda3/lib/python3.6/site-packages/zmq/backend/select.py", line 26, in select_backend
mod = __import__(name, fromlist=public_api)
File "/Users/jakesansom/anaconda3/lib/python3.6/site-packages/zmq/backend/cython/__init__.py", line 6, in <module>
from . import (constants, error, message, context,
ImportError: dlopen(/Users/jakesansom/anaconda3/lib/python3.6/site-packages/zmq/backend/cython/error.cpython-36m-darwin.so, 2): Symbol not found: _memset_s
Referenced from: /Users/jakesansom/anaconda3/lib/libsodium.23.dylib
Expected in: /usr/lib/libSystem.B.dylib
in /Users/jakesansom/anaconda3/lib/libsodium.23.dylib
I'm not sure if these issues are related or not, but I decided to post all of them just in case.

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.

Unable to install Python pip or use easy_install

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

Categories

Resources