Search code examples
pythonpython-3.xsslinstallationpip

Having trouble installing ssl with pip install: "SyntaxError: Missing parentheses in call to 'print'"


I'm trying to install SSL on my PC, but I keep getting the error below. Am I missing something really basic here? I tried upgrading my pip and upgrading setuptools, but nothing seems to work. any help would be greatly appreciated.

C:\Users\Michael\PycharmProjects\py4e>pip3 install ssl
Collecting ssl
  Using cached https://files.pythonhosted.org/packages/83/21/f469c9923235f8c36d5
fd5334ed11e2681abad7e0032c5aba964dcaf9bbb/ssl-1.16.tar.gz
    ERROR: Complete output from command python setup.py egg_info:
    ERROR: Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\MICHAE~1\AppData\Local\Temp\pip-install-qtieo4so\ssl\setup.
py", line 33
        print 'looking for', f
                          ^
    SyntaxError: Missing parentheses in call to 'print'. Did you mean print('loo
king for', f)?
    ----------------------------------------
ERROR: Command "python setup.py egg_info" failed with error code 1 in C:\Users\M
ICHAE~1\AppData\Local\Temp\pip-install-qtieo4so\ssl\

Solution

  • Given the error, it appears that your Python executable is Python 3.x (which requires print statements to be called with parentheses), but the package being installed is intended for Python 2.x. That likely means you need to upgrade your pip to Python 3 (you may already have it as pip3; i.e., try running pip3 install ssl).

    It appears that the ssl package in the PyPi repository only supports Python 2 (https://pypi.org/project/ssl/), but the ssl library is already built into Python 3 (https://docs.python.org/3/library/ssl.html)

    This means if you're using Python 3, no need to specify ssl in requirements.txt, if you do, you'll see the error from the question. Remove ssl from requirements.txt, and it will go away.