Trouble getting pip to work DistributionNotFound - python

i recently with Python coding a little programm with a simple GUI (Tkinter).
Now i need PIL to use images.
I want to install PIL using PIP but.
After installing PIP it always gives me this output:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 2872, in <module>
File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 451, in _build_master
def _build_from_requirements(cls, req_spec):
File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 464, in _build_from_requirements
for entry in sys.path:
File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 639, in resolve
fallback=True):
pkg_resources.DistributionNotFound: pip==1.5.6
Does anyone know what happend here?
I'm using Elementary OS Freya (Ubuntu 14.04)

Related

Pip is broken and I don't have admin permission

I have poured about 6 hours into this issue now and I'm getting farther and farther. Here's what happened.
I am using a shared Linux machine that has both Python 2.7 and Python 3.5 and I don't have admin privileges. I was using Python 3.5 and I wanted to use the package seaborn and I found out the specific labeling feature I wanted was only available in a newer version. So no problem "pip3 install seaborn --upgrade".
Everything was happening so fast but something went wrong and by the suggestion of the internet, I ended up upgrading a few other packages like matplotlib, setuptools, and eventually pip itself.
Here's where it really went wrong. Pip just broke. This happens when I run pip3 --version:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 33, in vendored
__import__(vendored_name, globals(), locals(), level=0)
ImportError: No module named 'pip._vendor.pkg_resources'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
from pip import main
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 13, in <module>
from pip.exceptions import InstallationError, CommandError, PipError
File "/usr/lib/python3/dist-packages/pip/exceptions.py", line 6, in <module>
from pip._vendor.six import iteritems
File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 75, in <module>
vendored("pkg_resources")
File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 36, in vendored
__import__(modulename, globals(), locals(), level=0)
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2927, in <module>
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2913, in _call_aside
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2952, in _initialize_master_working_set
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 956, in subscribe
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2952, in <lambda>
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2515, in activate
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2097, in declare_namespace
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2047, in _handle_ns
File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2066, in _rebuild_mod_path
AttributeError: '_NamespacePath' object has no attribute 'sort'
The first line in the call stack is "from pip import main" so I tried running pip --version instead of pip3 and now I get:
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
from pip import main
ImportError: cannot import name main
This error is all over the internet as a bug in pip itself but all every solution involves something that I don't have permission to do. I tried to uninstall and reinstall an older version of pip using "python -m pip ..." but this did not help with the pip3 error, which prompted the same error a few lines later. And I can't use this shortcut with pip3 (python3 -m pip...) because this error occurs anyway.
Worst part is that my original program is now completely dead. I can't even import seaborn at all without crashing.
Traceback (most recent call last):
File "/u/hailey/.local/lib/python3.5/site-packages/matplotlib/__init__.py", line 861, in __setitem__
cval = self.validate[key](val)
KeyError: 'axes.color_cycle'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "nn.py", line 9, in <module>
import seaborn as sns
File "/usr/lib/python3/dist-packages/seaborn/__init__.py", line 13, in <module>
set()
File "/usr/lib/python3/dist-packages/seaborn/rcmod.py", line 98, in set
set_palette(palette, color_codes=color_codes)
File "/usr/lib/python3/dist-packages/seaborn/rcmod.py", line 491, in set_palette
mpl.rcParams["axes.color_cycle"] = list(colors)
File "/u/hailey/.local/lib/python3.5/site-packages/matplotlib/__init__.py", line 868, in __setitem__
'list of valid parameters.' % (key,))
KeyError: 'axes.color_cycle is not a valid rc parameter. See rcParams.keys() for a list of valid parameters.'
At this point, I decided everything would be easier if I just downloaded my own clean version of Python in a local directory where I have privileges. So I downloaded and set up a new version of Python 3.6 in a local directory. Then I ran my original program with this and I was told I had no module named 'numpy'. Reasonable. Let's try to install numpy.
Obtaining file:///u/hailey/python36/Python-3.6.0
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/u/hailey/python36/Python-3.6.0/setup.py", line 4, in <module>
import sys, os, importlib.machinery, re, optparse
ImportError: No module named machinery
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /u/hailey/python36/Python-3.6.0/
Now I'm led to a page that recommends running "setup.py install", which sounds simple enough. But nope.
bash: /u/hailey/python36/Python-3.6.0/setup.py: Permission denied
Now I'm giving up because evidently I know nothing about Python. I would really appreciate some help with this. At this point, even just recovering the state I had yesterday would be fine as I can live without the extra label on my seaborn graph. Thanks everyone!

Whenever I do pip3 freeze or any pip3 command in my mac terminal, it raises a syntax error

Usually, pip3 works normally, but after installing tenser flow using pip, for some reason pip is not working anymore. For example, I did pip freeze to get my packages, but it came up with this error.
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/bin/pip", line 7, in <module>
from pip._internal import main
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_internal/__init__.py", line 42, in <module>
from pip._internal import cmdoptions
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_internal/cmdoptions.py", line 16, in <module>
from pip._internal.index import (
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_internal/index.py", line 24, in <module>
from pip._internal.download import HAS_TLS, is_url, path_to_url, url_to_path
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_internal/download.py", line 39, in <module>
from pip._internal.utils.logging import indent_log
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_internal/utils/logging.py", line 9, in <module>
from pip._internal.utils.misc import ensure_dir
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_internal/utils/misc.py", line 21, in <module>
from pip._vendor import pkg_resources
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3095, in <module>
#_call_aside
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3079, in _call_aside
f(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3123, in _initialize_master_working_set
for dist in working_set
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3123, in <genexpr>
for dist in working_set
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2633, in activate
declare_namespace(pkg)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2170, in declare_namespace
_handle_ns(packageName, path_item)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2105, in _handle_ns
loader.load_module(packageName)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pygoogle/google.py", line 118
%(__credits__)s""" % globals()
^
SyntaxError: invalid syntax
But when I do pip2 freeze it works completely normal.
I'm not sure if tenserflow is causing this, but it started happening after I installed it.
I have a mac os sierra 10.13.4, and did the commands on my terminal. I am using python 3.6.6 . Is there any way to fix this? I also tried uninstalling tensor flow.
It seems the cause of the problem is a Python 2.7 module somehow getting installed into python 3.6 folder. The guilty module is pygoogle. Uninstalling that may work. See:
https://www.pythonanywhere.com/forums/topic/12390/
Tensorflow SyntaxError with python 3.5.2

Python Eclipse PyDev

I am a complete newbie to Python.
I have downloaded and installed Anaconda 3.5.2 on Windows 7, then Eclipse Photon. Installed the PyDev Plugin.
I was able to run a few simple test programs in Eclipse.
Suddenly, without installing anything I get
Error processing line 1 of C:\Anaconda3\lib\site-packages\matplotlib-2.2.2-py3.6-nspkg.pth:
Failed to import the site module
Traceback (most recent call last):
File "C:\Anaconda3\lib\site.py", line 168, in addpackage
exec(line)
File "<string>", line 1, in <module>
File "C:\Anaconda3\lib\types.py", line 171, in <module>
import functools as _functools
File "C:\Anaconda3\lib\functools.py", line 21, in <module>
from collections import namedtuple
ImportError: cannot import name 'namedtuple'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Anaconda3\lib\site.py", line 541, in <module>
main()
File "C:\Anaconda3\lib\site.py", line 523, in main
known_paths = addsitepackages(known_paths)
File "C:\Anaconda3\lib\site.py", line 320, in addsitepackages
addsitedir(sitedir, known_paths)
File "C:\Anaconda3\lib\site.py", line 207, in addsitedir
addpackage(sitedir, name, known_paths)
File "C:\Anaconda3\lib\site.py", line 178, in addpackage
import traceback
File "C:\Anaconda3\lib\traceback.py", line 5, in <module>
import linecache
File "C:\Anaconda3\lib\linecache.py", line 8, in <module>
import functools
File "C:\Anaconda3\lib\functools.py", line 21, in <module>
from collections import namedtuple
ImportError: cannot import name 'namedtuple'
even with a "Hello World" which ran before
Any ideas what could cause this?
I have found the reason:
I have added a "PyDev Package" named "collections" in the IDE. This collided with something ....
You can try a few things. Have you tried updating the package in conda? It is possible it is not up to date. Also, with Eclipse (and with most IDEs) if things that were working a moment break without any changes it is a sign you should quit the program, give it a moment to settle, and try reopening and rerunning your code. Sometimes it is the tool's fault!

Run scrapy under windows 7

I want to create a new scrappy project under win 7. I have installed scrapy over pip and everthing went find.
I am using pip 1.0.1 from c:\python27\lib\site-packages (python 2.7).
I have added the C:\Python27\Scripts as my path variable.
However, when running scrapy in my cmd, I get:
C:\Users\User\EclipseWorkspace>scrapy
Traceback (most recent call last):
File "C:\Python27\Scripts\scrapy-script.py", line 5, in <module>
from pkg_resources import load_entry_point
File "C:\Python27\lib\site-packages\pkg_resources.py", line 2709, in <module>
working_set.require(__requires__)
File "C:\Python27\lib\site-packages\pkg_resources.py", line 686, in require
needed = self.resolve(parse_requirements(requirements))
File "C:\Python27\lib\site-packages\pkg_resources.py", line 584, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: six>=1.5.2
Any recommendation what I am doing wrong?
I appreciate your replies!
Update
When installing pip again I get:
C:\Users\User\EclipseWorkspace>pip --version
pip 6.0.6 from C:\Python27\lib\site-packages\pip-6.0.6-py2.7.egg (python 2.7)
However, when running scrapy:
C:\Users\User\EclipseWorkspace>scrapy
Traceback (most recent call last):
File "C:\Python27\Scripts\scrapy-script.py", line 5, in <module>
from pkg_resources import load_entry_point
File "C:\Python27\lib\site-packages\pkg_resources.py", line 2709, in <module>
working_set.require(__requires__)
File "C:\Python27\lib\site-packages\pkg_resources.py", line 686, in require
needed = self.resolve(parse_requirements(requirements))
File "C:\Python27\lib\site-packages\pkg_resources.py", line 584, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: six>=1.5.2

Django - ResolutionError and DistributionError

I had to uninstall my django==1.6.4 and install 1.5 for a project, but now when I install 1.6.4 with pip and try to start a project with django-admin.py startproject PN I get
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/bin/django-admin.py", line 5, in <module>
pkg_resources.run_script('Django==1.6.4', 'django-admin.py')
File "/Library/Python/2.7/site-packages/pkg_resources.py", line 534, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/Library/Python/2.7/site-packages/pkg_resources.py", line 1432, in run_script
raise ResolutionError("No script named %r" % script_name)
pkg_resources.ResolutionError: No script named 'django-admin.py'
martinssmacbook:bin martinspasov$ pip install django==1.6.4
I tried installing 1.6.5 but then when I try to start a project i get
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/bin/django-admin.py", line 4, in <module>
import pkg_resources
File "/Library/Python/2.7/site-packages/pkg_resources.py", line 2876, in <module>
working_set = WorkingSet._build_master()
File "/Library/Python/2.7/site-packages/pkg_resources.py", line 451, in _build_master
return cls._build_from_requirements(__requires__)
File "/Library/Python/2.7/site-packages/pkg_resources.py", line 464, in _build_from_requirements
dists = ws.resolve(reqs, Environment())
File "/Library/Python/2.7/site-packages/pkg_resources.py", line 639, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: Django==1.6.4
Any ideas onwhat to do ?
this is because you should delete all 1.6.4 files and then install 1.6.5.
but now there are also 1.6.4 files in your Linux / windows.
in windows,
you should delete the files in python/lib/site-packages/django
to uninstall the main Django files.
nd then delete Django-VERSION-py2.7.egg or fix the VERSION in
it. not just these.
you have to delete following 4 files:
django-admin.exe, django-admin.py,django-admin.exe.manifest,django-admin-script.py
then you can reinstall the django.
(In fact, if you know the file, you can try to edit it with change the version.)
in Linux, you can do like that.
if there 's something wrong, you can try to delete all.

Categories