0

I cannot import mysql.connector in python 2.7.12. I cannot upgrade my python version, because some other servers are running on it.

>>> import mysql.connector
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\mysql\connector\__init__.py", line 53, in <module>
    from .connection import MySQLConnection
  File "C:\Python27\lib\site-packages\mysql\connector\connection.py", line 518
    f"This connection is using {tls_version} which is now "
                                                          ^
SyntaxError: invalid syntax

This is the error I am getting even though I installed mysql-connector-python. Can someone please help me with this?

  • 1
    Does this answer your question? [f-strings giving SyntaxError?](https://stackoverflow.com/questions/50401632/f-strings-giving-syntaxerror) – mkrieger1 Jul 18 '22 at 21:42
  • Whatever version of `mysql` you're using only supports python 3.6+. You're going to need to pin to an earlier version of `mysql` that supports 2.7 – astrochun Jul 19 '22 at 00:16

1 Answers1

0

As I stated in my comment, you're most likely using a more recent mysql-connector-python.

From the list of version in PyPI, this might be the last one that supports 2.7: https://pypi.org/project/mysql-connector-python/8.0.23/

This docs discusses that 2.7 was removed in 8.0.24:

astrochun
  • 1,642
  • 2
  • 7
  • 18