Python 3.5 pip version conflict with python 2.7 - python

I am trying to install a software using pip install and my python and pip versions are 3.5. but when I run sudo pip install -e . I get the following error.
Traceback (most recent call last):
File "/usr/local/bin/pip3.5", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/local/lib/python2.7/dist-packages/distribute-0.6.14-py2.7.egg/pkg_resources.py", line 2675, in <module>
parse_requirements(__requires__), Environment()
File "/usr/local/lib/python2.7/dist-packages/distribute-0.6.14-py2.7.egg/pkg_resources.py", line 552, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pip==8.1.0
Why Do I get an error with python 2.7 and please some one could sortout my issue.

Your pip version and python versions are separate. It looks like your package requires exactly pip 8.1.0. You have to either upgrade/downgrade to that version first, or modify the software to work with whichever pip you have available.
Also, it may be easier to install the software in a virtual environment rather than system/global one. Changing the system version of pip may break either current apps, or the future pip package updates.

Related

Python3.7 on Windows Ubuntu Bash shell ImportError: cannot import name 'HTTPSHandler' from 'urllib.request' (/usr/lib/python3.7/urllib/request.py)

I've recently updated Python to version 3.7 from version 3.5, and made it the default in my bash shell. I've also updated pip and made sure it uses Python3.7.
Now, whenever I try to install any module using pip I get this error"
$pip3 install google
Traceback (most recent call last): File "/home/AnnaK/.local/bin/pip3", line 7, in <module>
from pip._internal.cli.main import main File "/usr/lib/python3/dist-packages/pip/__init__.py", line 16, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa File "/usr/lib/python3/dist-packages/pip/vcs/subversion.py", line 9, in <module>
from pip.index import Link File "/usr/lib/python3/dist-packages/pip/index.py", line 30, in <module>
from pip.wheel import Wheel, wheel_ext File "/usr/lib/python3/dist-packages/pip/wheel.py", line 39, in <module>
from pip._vendor.distlib.scripts import ScriptMaker File "/usr/share/python-wheels/distlib-0.2.2-py2.py3-none-any.whl/distlib/scripts.py", line 14, in <module> File "/usr/share/python-wheels/distlib-0.2.2-py2.py3-none-any.whl/distlib/compat.py", line 66, in <module> ImportError: cannot import name 'HTTPSHandler' from 'urllib.request' (/usr/lib/python3.7/urllib/request.py)
I get the same error if I try to simply run pip. This didn't happen when I was using python3.5. I did have this problem when briefly using python2.7, but I fixed it using https://askubuntu.com/questions/581999/pip-raises-importerror-cannot-import-name-httpshandler. That solution doesn't seem to work for python3.7.
I've tried to reinstall pip, reinstall python3, update my Windows Ubuntu subsystem, and reinstall libssl-dev. I'm stumped. Any help is appreciated!
You must have inadvertently upgraded your system pip (probably through something like sudo pip install pip --upgrade)
pip x.x adjusts where its internals are situated. The pip3 command you're seeing is one provided by your package maintainer and is not a file managed by pip.
You can read more about this on pip's issue tracker
You'll probably want to not upgrade your system pip and instead use a virtualenv.
To recover the pip3 binary you'll need to sudo python3 -m pip uninstall pip && sudo apt install python3-pip --reinstall.
It should work fine if you use the first approach python3 -m pip ... instead of pip3 ....

PIP raising SyntaxError from command line

I have attempted to install PIP using the following commands:
sudo yum install python-setuptools
sudo easy_install pip
sudo pip install supervisor
As it installed, a number of syntax errors were raised from the second and third lines. The errors are fairly similar to that below, so for brevity I'll omit here, but let me know if having those will help. There are a lot.
When I run any pip command, I get SyntaxErrors:
# pip
Traceback (most recent call last):
File "/usr/bin/pip", line 7, in ?
sys.exit(
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 236, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 2097, in load_entry_point
return ep.load()
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 1830, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/lib/python2.4/site-packages/pip-8.1.1-py2.4.egg/pip/__init__.py", line 208
except PipError as exc:
^
SyntaxError: invalid syntax
I am running CentOS release 5.11 (Final) and Python 2.4.3 (#1, Jan 9 2013, 06:47:03). Note, these are managed by WHM.
I have re-installed PIP using python get-pip.py --ignore-installed, but get the same result.
Is this a Python version conflict? Is my version of Python too old and the syntax in the PIP scripts different? What should I do?
except PipError as exc: isn't a valid Python 2.4 syntax (it should be except PipError, exc).
I don't think pip is meant to work with Python 2.4. Try this question for installing PIP 1.1, which is compatible with that version of Python:
Installing Pip on 2.4
As the above answer describes, you've run into version conflicts between pip and python. You're using an old version of CentOS with an old version of python 2, which makes things worse.
Updating the system environment with 'sudo pip' has a very high risk of creating version problems with system utilities. You can, for instance, break yum, and be forced to update your system with rpm commands. You need to install a recent version of python (preferably python 3) as an alternate install in /usr/local/bin or in a user directory.
Then I highly recommend using a virtual environment (https://virtualenv.pypa.io/en/latest/, or a built-in capability in python 3.5). That lets you set up your own python executable, libraries, and installed packages any way you like, without risk of affecting your entire system. It's a minor setup pain, but it makes most of the problems just vanish.

"InvalidRequirement: Invalid requirement, parse error" error after updating a python package

After updating a package (IPython in my case) using pip install -U ipython running any Python script that uses entry points fails with this error:
Traceback (most recent call last):
File "/home/adrian/dev/indico/env/bin/indico", line 5, in <module>
from pkg_resources import load_entry_point
...
File "/home/adrian/dev/indico/env/lib/python2.7/site-packages/pkg_resources/_vendor/packaging/requirements.py", line 94, in __init__
requirement_string[e.loc:e.loc + 8], requirement_string))
pkg_resources._vendor.packaging.requirements.InvalidRequirement: Invalid requirement, parse error at "'< 2.0'"
Nothing else changed, I did not update any other libraries.
This is caused by an issue in setuptools==20.2.1 which is pulled in by IPython (setuptools>..), so a pip install -U updated it.
Until a fixed version is released or the broken version is pulled from PyPI there is a simple workaround (but note that it will break again if something updates setuptools):
pip install -U pip
pip uninstall setuptools
pip install 'setuptools<20.2'
The pip update is needed since older versions of pip will not work without setuptools being installed
See these IRC logs and BitBucket issue for details:
http://chat-logs.dcpython.org/day/pypa/2016-02-25
https://bitbucket.org/pypa/setuptools/issues/502/packaging-164-does-not-allow-whitepace
Try downgrading your pip to 8.1.1:
pip install pip==8.1.1
That solved it for me.
In my case I had package = "2.8.0" in my Pipfile. Changing it to package = "==2.8.0" fixed this error for me.

python can't find numpy

I was trying to follow the instruction from this link :http://www.thisisthegreenroom.com/2011/installing-python-numpy-scipy-matplotlib-and-ipython-on-lion/
However, it seems my python can not find the Numpy, Scipy and everything I install using pip.
Right now, when I type which python, it shows /usr/local/bin/python.
However, when I type
pip install numpy
it shows
Requirement already satisfied (use --upgrade to upgrade): numpy in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python.
Thus it seems they are in different directory, and probably I installed numpy previously, which makes pip keep telling me they are installed. I wonder is there any way around that ?
update, I have tried to import it.
import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named numpy
I have also tried to uninstall the numpy and install it again. However, when I uninstall it. It still gives me error.
applematoMacBook-Air:~ apple$ pip uninstall numpy
DEPRECATION: Uninstalling a distutils installed project (numpy) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
Uninstalling numpy-1.8.0rc1:
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8.0rc1-py2.7.egg-info
Proceed (y/n)? y
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/pip-6.1.1-py2.7.egg/pip/basecommand.py", line 246, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/site-packages/pip-6.1.1-py2.7.egg/pip/commands/uninstall.py", line 70, in run
requirement_set.uninstall(auto_confirm=options.yes)
File "/usr/local/lib/python2.7/site-packages/pip-6.1.1-py2.7.egg/pip/req/req_set.py", line 274, in uninstall
req.uninstall(auto_confirm=auto_confirm)
File "/usr/local/lib/python2.7/site-packages/pip-6.1.1-py2.7.egg/pip/req/req_install.py", line 730, in uninstall
paths_to_remove.remove(auto_confirm)
File "/usr/local/lib/python2.7/site-packages/pip-6.1.1-py2.7.egg/pip/req/req_uninstall.py", line 126, in remove
renames(path, new_path)
File "/usr/local/lib/python2.7/site-packages/pip-6.1.1-py2.7.egg/pip/utils/__init__.py", line 292, in renames
shutil.move(old, new)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move
os.unlink(src)
OSError: [Errno 13] Permission denied: '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8.0rc1-py2.7.egg-info'
Seems like the version of pip you are using is using the default mac system-wide python interpreter /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python instead of the one installed in /usr/local/bin.
I've pretty much experienced the same issues until I started using homebrew. I'd recommend to have a look at this page on brew and python. You'd might need to remove pip and reinstall it from brew. Btw, using brew, there's no need for sudo.
try: pip uninstall numpy
and then: pip install numpy
...and try it with sudo:
sudo pip install numpy
first, you should use pip list to check out have you installed numpy .
if you already installed, check out your program IDE whether the pycharm, and check the pycharm interpreter does the local interpreter or virtual interpreter. if the interpreter is virtual, you should change to local. if it works, you can create the new project with select the local interpreter.
more detail: https://www.jianshu.com/p/9c3507cca2b9
in my problem, i can't update scikit-learn with pip install -U scikit-learn, and occur the problem
Cannot uninstall 'scikit-learn'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
it occured in your error too. so, i find your problem.
and i try the commod pip install -U --ignore-installed scikit-learn, and it solve my problem.

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