I installed pip from this command
curl https://bootstrap.pypa.io/get-pip.py --output get-pip.py
and when I did sudo python2 get-pip.py
Traceback (most recent call last):
File "get-pip.py", line 24226, in <module>
main()
File "get-pip.py", line 199, in main
bootstrap(tmpdir=tmpdir)
File "get-pip.py", line 82, in bootstrap
from pip._internal.cli.main import main as pip_entry_point
File "/tmp/tmpf3jeCG/pip.zip/pip/_internal/cli/main.py", line 60
sys.stderr.write(f"ERROR: {exc}")
^
SyntaxError: invalid syntax
It was working fine a few weeks back and then suddenly it has stopped working. I really need to know what I have done wrong? Is there any other way I can do it? I'm using Atlassian Bitbucket which has Java8 image. I also need pip installed since I can not have more than one image. I'm downloading it locally using the above command and making pip work. Is there anyother way I can use it to make it work?
If you get a "SyntaxError: invalid syntax" when trying to install a module using pip , make sure to run the command from your shell, e.g. bash or PowerShell, and not by running a Python file that contains the pip install your_module command.
The python pip invalid syntax error is occurring because pip is run from the command line, not the Python interpreter. It is a program that installs modules, so you can use them from Python. Once you have installed the module, then you can open the Python shell and do import selenium.
Defining and Calling Functions You can clear up this invalid syntax in Python by switching out the semicolon for a colon. Here, once again, the error message is very helpful in telling you exactly what is wrong with the line.
The support for Python 2.7 is deprecated on newer versions of pip, hence the reason why you're noticing this error here.
In order for you to maintain the sanity with Python 2.7 and pip, either maintain yourself to lower version of pip using the pip installer itself
pip install --upgrade pip==20.3
or make use of the Python 2.7 specific version of get-pip.py
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With