1

After upgrading from Django 1.6 to 1.7, all was fine in dev when using the built-in runserver. However, after deploying on Apache with mod_wsgi, an error occured when django-mssql was used:

Traceback (most recent call last):
...
  File "C:\\Python27\\lib\\site-packages\\django\\db\\models\\query.py", line 141, in __iter__
    self._fetch_all()
  File "C:\\Python27\\lib\\site-packages\\django\\db\\models\\query.py", line 966, in _fetch_all
    self._result_cache = list(self.iterator())
  File "C:\\Python27\\lib\\site-packages\\django\\db\\models\\query.py", line 1224, in iterator
    for row in self.query.get_compiler(self.db).results_iter():
  File "C:\\Python27\\lib\\site-packages\\django\\db\\models\\sql\\compiler.py", line 701, in results_iter
    for rows in self.execute_sql(MULTI):
  File "C:\\Python27\\lib\\site-packages\\django\\db\\models\\sql\\compiler.py", line 785, in execute_sql
    cursor = self.connection.cursor()
  File "C:\\Python27\\lib\\site-packages\\django\\db\\backends\\__init__.py", line 167, in cursor
    cursor = utils.CursorWrapper(self._cursor(), self)
  File "C:\\Python27\\lib\\site-packages\\django\\db\\backends\\__init__.py", line 138, in _cursor
    self.ensure_connection()
  File "C:\\Python27\\lib\\site-packages\\django\\db\\backends\\__init__.py", line 133, in ensure_connection
    self.connect()
  File "C:\\Python27\\lib\\site-packages\\django\\db\\backends\\__init__.py", line 122, in connect
    self.connection = self.get_new_connection(conn_params)
  File "C:\\Python27\\lib\\site-packages\\sqlserver_ado\\base.py", line 244, in get_new_connection
    conn = Database.connect(**conn_params)
  File "C:\\Python27\\lib\\site-packages\\sqlserver_ado\\dbapi.py", line 171, in connect
    import pythoncom
  File "C:\\Python27\\lib\\site-packages\\pythoncom.py", line 2, in <module>
    import pywintypes
  File "C:\\Python27\\lib\\site-packages\\win32\\lib\\pywintypes.py", line 124, in <module>
    __import_pywin32_system_module__("pywintypes", globals())
  File "C:\\Python27\\lib\\site-packages\\win32\\lib\\pywintypes.py", line 98, in __import_pywin32_system_module__
    raise ImportError("No system module '%s' (%s)" % (modname, filename))
ImportError: No system module 'pywintypes' (pywintypes27.dll)

There was no problem previously with Django 1.6. It shouldn't be a problem with django-mssql since I didn't upgrade that package.

Copying the py*.dll files to C:\Python27 according to another post worked, so the question is: why is this necessary now in Django 1.7 since it was fine in Django 1.6?

Community
  • 1
  • 1
user193130
  • 8,009
  • 4
  • 36
  • 64
  • Does the web server user have access to that DLL? – Ignacio Vazquez-Abrams Jul 31 '15 at 17:51
  • @IgnacioVazquez-Abrams Yes, since all I did was upgrade Django 1.6 to Django 1.7. Those dlls are normally sitting in `C:\Python27\Lib\site-packages\pywin32_system32`, but for some reason, it has to be copied to `C:\Python27` after the upgrade. – user193130 Jul 31 '15 at 17:54

0 Answers0