title: SyntaxError: invalid syntax on lib/python3.8/site-packages/sql_server/pyodbc/base.py django deploy on Linux
body: <p>**</p>
  <ol>
  <li>Preface (Testing HyperV Virtual Server with os: Ubuntu Server 20.04.1 on local Windows PC)</li>
  </ol>
  <p>**</p>
  <p>I am having problems deploying my Django app (using Python 3.8.2) on a Ubuntu Server 20.04.1 LTS that uses MS SQL Server as its database. No issues reverting back to 'ENGINE': 'django.db.backends.sqlite3' on Linux but I have to be honest, it is frustrating.</p>
  <p>I already had to downgrade to Django==3.0 to get my app working on my local windows pc but the 2 migrations I did proves that I am missing something and I hope someone can give me a hand. Any help is appreciated.</p>
  <ol>
  <li><strong>My PC</strong></li>
  </ol>
  <p>Working settings.py file (currently running on windows with Sql Server 2019 Express</p>
  <pre><code>    DATABASES = {
      'default': {
          'ENGINE': 'sql_server.pyodbc',
          'NAME': 'mdm_db',
          'USER': 'AAA',
          'PASSWORD': 'AAA',
           'HOST': 'localhost\\SQLEXPRESS',
          'PORT': '',
  
          'OPTIONS': {
              'driver': 'SQL Server Native Client 11.0',
              # 'driver': 'ODBC Driver 13 for SQL Server ', -&gt; port 1433?
          },
      },
      }
  installed components:
      pip freeze
      asgiref==3.2.10
      Django==3.0
      django-mssql-backend==2.8.1
      pyodbc==4.0.30
      pytz==2020.1
      sql-server.pyodbc==1.0
      sqlparse==0.3.1
  </code></pre>
  <ol start="3">
  <li><strong>Ubuntu Server</strong></li>
  </ol>
  <p>(also tried using ODBC and installing the latest version <a href="https://docs.microsoft.com/it-it/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver15" rel="nofollow noreferrer">https://docs.microsoft.com/it-it/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver15</a>)</p>
  <pre><code>DATABASES = {
      'default': {
          'ENGINE': 'sql_server.pyodbc',
          'NAME': 'mdm_db',
          'USER': 'mdmuser',
          'PASSWORD': 'mdmuser',
           'HOST': 'localhost\\SQLEXPRESS',
          'PORT': '',
          'OPTIONS': {
              #'driver': 'SQL Server Native Client 11.0',
               'driver': 'ODBC Driver 17 for SQL Server ',
          },
      },
      }
  </code></pre>
  <p>Packages installed</p>
  <pre><code>:~/app/MDM_SQLServer$ history | grep install
  
     32  sudo apt-get install unixodbc-dev
     34  sudo apt-get install python3-dev
     36  sudo apt-get install build-essential libssl-dev libffi-dev python3-dev
     60  sudo ACCEPT_EULA=Y apt-get install msodbcsql17
  </code></pre>
  <ol start="4">
  <li>Issue: (venv) luca@webserver:~/app/MDM_SQLServer$ python manage.py runserver</li>
  </ol>
  <hr />
  <pre><code>Watching for file changes with StatReloader
  Exception in thread django-main-thread:
  Traceback (most recent call last):
    File &quot;/usr/lib/python3.8/threading.py&quot;, line 932, in _bootstrap_inner
      self.run()
    File &quot;/usr/lib/python3.8/threading.py&quot;, line 870, in run
      self._target(*self._args, **self._kwargs)
    File &quot;/home/luca/app/venv/lib/python3.8/site-packages/django/utils/autoreload.py&quot;, line 53, in wrapper
      fn(*args, **kwargs)
    File &quot;/home/luca/app/venv/lib/python3.8/site-packages/django/core/management/commands/runserver.py&quot;, line 109, in inner_run
      autoreload.raise_last_exception()
    File &quot;/home/luca/app/venv/lib/python3.8/site-packages/django/utils/autoreload.py&quot;, line 76, in raise_last_exception
      raise _exception[1]
    File &quot;/home/luca/app/venv/lib/python3.8/site-packages/django/core/management/__init__.py&quot;, line 357, in execute
      autoreload.check_errors(django.setup)()
    File &quot;/home/luca/app/venv/lib/python3.8/site-packages/django/utils/autoreload.py&quot;, line 53, in wrapper
      fn(*args, **kwargs)
    File &quot;/home/luca/app/venv/lib/python3.8/site-packages/django/__init__.py&quot;, line 24, in setup
      apps.populate(settings.INSTALLED_APPS)
    File &quot;/home/luca/app/venv/lib/python3.8/site-packages/django/apps/registry.py&quot;, line 114, in populate
      app_config.import_models()
    File &quot;/home/luca/app/venv/lib/python3.8/site-packages/django/apps/config.py&quot;, line 211, in import_models
      self.models_module = import_module(models_module_name)
    File &quot;/usr/lib/python3.8/importlib/__init__.py&quot;, line 127, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 1014, in _gcd_import
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 991, in _find_and_load
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 975, in _find_and_load_unlocked
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 671, in _load_unlocked
    File &quot;&lt;frozen importlib._bootstrap_external&gt;&quot;, line 783, in exec_module
    File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 219, in _call_with_frames_removed
    File &quot;/home/luca/app/MDM_SQLServer/cpus/models.py&quot;, line 6, in &lt;module&gt;
      from sites.models import Site
    File &quot;/home/luca/app/MDM_SQLServer/sites/models.py&quot;, line 4, in &lt;module&gt;
      from wifis.models import Wifi
    File &quot;/home/luca/app/MDM_SQLServer/wifis/models.py&quot;, line 3, in &lt;module&gt;
      class Wifi(models.Model):
    File &quot;/home/luca/app/venv/lib/python3.8/site-packages/django/db/models/base.py&quot;, line 121, in __new__
      new_class.add_to_class('_meta', Options(meta, app_label))
    File &quot;/home/luca/app/venv/lib/python3.8/site-packages/django/db/models/base.py&quot;, line 325, in add_to_class
      value.contribute_to_class(cls, name)
    File &quot;/home/luca/app/venv/lib/python3.8/site-packages/django/db/models/options.py&quot;, line 208, in contribute_to_class
      self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
    File &quot;/home/luca/app/venv/lib/python3.8/site-packages/django/db/__init__.py&quot;, line 28, in __getattr__
      return getattr(connections[DEFAULT_DB_ALIAS], item)
    File &quot;/home/luca/app/venv/lib/python3.8/site-packages/django/db/utils.py&quot;, line 207, in __getitem__
      backend = load_backend(db['ENGINE'])
    File &quot;/home/luca/app/venv/lib/python3.8/site-packages/django/db/utils.py&quot;, line 111, in load_backend
      return import_module('%s.base' % backend_name)
    File &quot;/usr/lib/python3.8/importlib/__init__.py&quot;, line 127, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File &quot;/home/luca/app/venv/lib/python3.8/site-packages/sql_server/pyodbc/base.py&quot;, line 7
      except ImportError, e:
                        ^
  SyntaxError: invalid syntax
  </code></pre>
  <p>NOTE Prompt is not returned, I need to corntol+C out.</p>
  <p>Test2 New Env</p>
  <pre><code>luca@webserver:~/app/MDM_SQLServer$ source test2/bin/activate
  (test2) luca@webserver:~/app/MDM_SQLServer$ pipinstall -r req
  req.txt           requirements.txt
  (test2) luca@webserver:~/app/MDM_SQLServer$ pipinstall -r req.txt
  pipinstall: command not found
  (test2) luca@webserver:~/app/MDM_SQLServer$ pip install -r req.txt
  Collecting asgiref==3.2.10
    Using cached asgiref-3.2.10-py3-none-any.whl (19 kB)
  Collecting Django==3.0
    Using cached Django-3.0-py3-none-any.whl (7.4 MB)
  Collecting django-mssql-backend==2.8.1
    Using cached django_mssql_backend-2.8.1-py3-none-any.whl (52 kB)
  Collecting pyodbc==4.0.30
    Using cached pyodbc-4.0.30.tar.gz (266 kB)
  Collecting pytz==2020.1
    Using cached pytz-2020.1-py2.py3-none-any.whl (510 kB)
  Processing /home/luca/.cache/pip/wheels/a9/78/cf/dc91ed794c352243f2796a29991293fd578c91f6584b0682f7/sql_server.pyodbc-1.0-py3-none-any.whl
  Collecting sqlparse==0.3.1
    Using cached sqlparse-0.3.1-py2.py3-none-any.whl (40 kB)
  Building wheels for collected packages: pyodbc
    Building wheel for pyodbc (setup.py) ... error
    ERROR: Command errored out with exit status 1:
     command: /home/luca/app/MDM_SQLServer/test2/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '&quot;'&quot;'/tmp/pip-install-tth7v6fw/pyodbc/setup.py'&quot;'&quot;'; __file__='&quot;'&quot;'/tmp/pip-install-tth7v6fw/pyodbc/setup.py'&quot;'&quot;';f=getattr(tokenize, '&quot;'&quot;'open'&quot;'&quot;', open)(__file__);code=f.read().replace('&quot;'&quot;'\r\n'&quot;'&quot;', '&quot;'&quot;'\n'&quot;'&quot;');f.close();exec(compile(code, __file__, '&quot;'&quot;'exec'&quot;'&quot;'))' bdist_wheel -d /tmp/pip-wheel-lr00jtg6
         cwd: /tmp/pip-install-tth7v6fw/pyodbc/
    Complete output (6 lines):
    usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
       or: setup.py --help [cmd1 cmd2 ...]
       or: setup.py --help-commands
       or: setup.py cmd --help
  
    error: invalid command 'bdist_wheel'
    ----------------------------------------
    ERROR: Failed building wheel for pyodbc
    Running setup.py clean for pyodbc
  Failed to build pyodbc
  Installing collected packages: asgiref, pytz, sqlparse, Django, pyodbc, django-mssql-backend, sql-server.pyodbc
      Running setup.py install for pyodbc ... done
  Successfully installed Django-3.0 asgiref-3.2.10 django-mssql-backend-2.8.1 pyodbc-4.0.30 pytz-2020.1 sql-server.pyodbc-1.0 sqlparse-0.3.1
  (test2) luca@webserver:~/app/MDM_SQLServer$
  </code></pre>
  <p>Thanks in advance</p>