0

I am trying to install packages with pip but every time I run a command this error pops up, I have tried repairing Python but still can not get it to work. I'm new to coding python so I'm not really sure what to do here. Thanks.

Traceback (most recent call last):
  File "C:\Users\sachl\.windows-build-tools\python27\lib\runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "C:\Users\sachl\.windows-build-tools\python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Users\sachl\.windows-build-tools\python27\lib\site-packages\pip\__main__.py", line 21, in <module>
    from pip._internal.cli.main import main as _main
  File "C:\Users\sachl\.windows-build-tools\python27\lib\site-packages\pip\_internal\cli\main.py", line 60
    sys.stderr.write(f"ERROR: {exc}")
                                   ^
SyntaxError: invalid syntax 
samleews
  • 1
  • 1

1 Answers1

1

Looks like there's a confusion of Python versions; the filenames suggest Python 2.7 (directory name python27), but the code is Python 3.6 or later (strings prefixed with f", known as f-strings).

You'll need to reinstall matching versions of python and pip; probably the latest (Python 3.x), unless you have reason to use 2.7 specifically.

Jiří Baum
  • 6,697
  • 2
  • 17
  • 17