pip broken with this errer - python

$ pip install selenium
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}")
^
SyntaxError: invalid syntax
I hope to install selenium to make crawling images, but this message makes me crazy. I can't googling this error as it is too long and I can't understand.
I tried to reinstall python with and pip with this code
$ curl -O https://bootstrap.pypa.io/2.7/get-pip.py
$ python get-pip.py
$ python -m pip install --upgrade "pip < 21.0"
I just started to study programming. Plz let me know what is wrong.

I just found what I did wrong.
I used pip instead pip3
With pip3, It works...
For someone in such a problem, I leave this post

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

How to install mtools by pip on Mac OS?

I followed this instruction to install mtools: https://github.com/rueckstiess/mtools/blob/develop/INSTALL.md. I tried both by pip and building from source but failed to launch it. I got below error when trying to launch mlaunch. I see this error relates to python and I am not familiar with python. Does anyone have any idea on this error?
$ mlaunch
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/bin/mlaunch", line 9, in <module>
load_entry_point('mtools==1.2.4.dev0', 'console_scripts', 'mlaunch')()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 565, 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 2697, in load_entry_point
return ep.load()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2370, in load
return self.resolve()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2376, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mtools-1.2.4.dev0-py2.7.egg/mtools/mlaunch/mlaunch.py", line 40, in <module>
raise ImportError("Can't import pymongo. See http://api.mongodb.org/python/current/ for instructions on how to install pymongo.")
ImportError: Can't import pymongo. See http://api.mongodb.org/python/current/ for instructions on how to install pymongo.
The error message in the trace states:
ImportError: Can't import pymongo. See http://api.mongodb.org/python/current/ for instructions on how to install pymongo.
This means that you are missing a dependency called pymongo to run mlaunch.
You can install pymongo by running the following command:
python -m pip install pymongo
For more information on how to install pymongosee the official documentation: https://api.mongodb.com/python/current/installation.html

Error after installing pip with easy install (on mac)

I tried to download pip with easy install but after installation whenever I type pip into the mac terminal it gives me this error:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 8, in <module>
load_entry_point('pip==7.0.3', 'console_scripts', 'pip')()
File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 271, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 2173, in load_entry_point
return ep.load()
File "/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/pkg_resources.py", line 1906, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/Library/Python/2.5/site-packages/pip-7.0.3-py2.5.egg/pip/__init__.py", line 211
except PipError as exc:
^
SyntaxError: invalid syntax
and when I try to do pip install pyopengl, it gives me the same error. What do I do to fix this?
Modern pip works with Python 2.6 and higher. It seems you got Python 2.5, so you either need to upgrade Python or use older version of pip.
According to the documentation Python 2.5 was supported through v1.3.1 of pip.

broken easy_install and pip after upgrading to OS X Mavericks

Upgraded to OS X 10.9 Mavericks and installed XCode, Command Line Tools, XQuartz, etc. Trying to run a pip install now, but it says that the distribution is not found:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, 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 2603, in <module>
working_set.require(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 666, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: pip==1.4.1
So I tried to install pip with an easy_install. Turns out that's borked too:
Traceback (most recent call last):
File "/usr/local/bin/easy_install", line 5, 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 2607, in <module>
parse_requirements(__requires__), Environment()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: setuptools==1.1.6
So some of the other threads say to reinstall setuptools with a sudo python ez_setup.py. It seems to work fine:
Installed /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-1.1.6-py2.7.egg
Processing dependencies for setuptools==1.1.6
Finished processing dependencies for setuptools==1.1.6
But when running the easy_install pip, the same pkg_resources.DistributionNotFound: setuptools==1.1.6 error occurs. Anyone else have this problem? Any ideas how to fix this?
Install easy_install:
Download ez_setup.py module from https://pypi.python.org/pypi/setuptools
$ cd path/to/ez_setup.py
$ python ez_setup.py
Install pip:
$ sudo easy_install pip
try sudo python -m easy_install pip
I ran into a similar problem with git-review.
$ git review -s
Traceback (most recent call last):
File "/usr/local/bin/git-review", line 11, in <module>
sys.exit(main())
File "/Library/Python/2.7/site-packages/git_review/cmd.py", line 1132, in main
(os.path.split(sys.argv[0])[-1], get_version()))
File "/Library/Python/2.7/site-packages/git_review/cmd.py", line 180, in get_version
provider = pkg_resources.get_provider(requirement)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 197, in get_provider
return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 666, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: git-review
The git-review team said it was a bug with pkg_resources that could be fixed with
sudo pip install --upgrade setuptools
This worked fine for me.

Pytest Version Conflict Error

After update of Debian (Jessie), pytest doesn't work :
#py.test
Traceback (most recent call last):
File "/usr/bin/py.test", line 5, in <module>
sys.exit(load_entry_point('pytest==2.4.2', 'console_scripts', 'py.test')())
File "/usr/local/lib/python2.7/dist-packages/pkg_resources.py", line 348, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python2.7/dist-packages/pkg_resources.py", line 2311, in load_entry_point
return ep.load()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources.py", line 2024, in load
if require: self.require(env, installer)
File "/usr/local/lib/python2.7/dist-packages/pkg_resources.py", line 2037, in require
working_set.resolve(self.dist.requires(self.extras),env,installer)))
File "/usr/local/lib/python2.7/dist-packages/pkg_resources.py", line 571, in resolve
raise VersionConflict(dist,req) # XXX put more info here
pkg_resources.VersionConflict: (py 1.4.15 (/usr/lib/python2.7/dist-packages), Requirement.parse('py>=1.4.17'))
How can I fix this error? Thanx in advance!
The files in /usr/local/lib/python2.7/dist-packages belong to python packages you installed with pip, easy_install or python setup.py. The system update probably messed up some dependencies. Does this work?
sudo apt-get install python-pip
sudo /usr/bin/pip install -U pytest
Some instances might have more than one pytest running.
Try:
sudo apt-get remove pytest
Then run your test again.

Categories

Resources