Django also runs on Windows, and I have operated it there for testing
purposes, but it is most at home in a Linux environment.
I have never (personally) run it in a container. I prefer the better
performance and ease of use when installed directly on the server.
Containers may deploy more quickly, but you pay a penalty for the rest of
the life of the system.
I cannot imagine why one would want to run * anything * in a Windows
container. That is adding complexity on top of difficulty.
My suggestion is to eliminate Windows from your thinking and run django
directly on Linux.
Use Windows for desktops or laptops, use Linux for servers.
(full disclosure: this message is being typed on an Ubuntu Linux desktop.)


On Wed, May 18, 2022 at 3:49 PM Ankit Sharma <sharmaji.ankit...@gmail.com>
wrote:

> Hi Team,
>
> Hope this mail finds you well!
>
> The issue with Pywin32 library is , it is getting deployed successfully to
> window container, However, once we try to use Export file function from the
> library , we get following error:
>
> "Environment:
>
>
> Request Method: GET
> Request URL:
> http://globalinnovationfitdjango-window.azurewebsites.net/export_report?projectId=2538
>
> Django Version: 3.0.5
> Python Version: 3.8.10
> Installed Applications:
> ['django.contrib.admin',
>  'django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.messages',
>  'django.contrib.staticfiles',
>  'django.contrib.sites',
>  'corsheaders',
>  'rest_framework',
>  'projects',
>  'channels_menu']
> Installed Middleware:
> ['corsheaders.middleware.CorsMiddleware',
>  'django.middleware.security.SecurityMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.middleware.common.CommonMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>  'django.contrib.messages.middleware.MessageMiddleware',
>  'django.middleware.clickjacking.XFrameOptionsMiddleware']
>
>
>
> Traceback (most recent call last):
>   File "C:\Python\lib\site-packages\win32com\client\dynamic.py", line 86,
> in _GetGoodDispatch
>     IDispatch = pythoncom.connect(IDispatch)
>
> During handling of the above exception ((-2147221005, 'Invalid class
> string', None, None)), another exception occurred:
>   File "C:\Python\lib\site-packages\django\core\handlers\exception.py",
> line 34, in inner
>     response = get_response(request)
>   File "C:\Python\lib\site-packages\django\core\handlers\base.py", line
> 115, in _get_response
>     response = self.process_exception_by_middleware(e, request)
>   File "C:\Python\lib\site-packages\django\core\handlers\base.py", line
> 113, in _get_response
>     response = wrapped_callback(request, *callback_args, **callback_kwargs)
>   File "C:\Python\lib\site-packages\django\views\decorators\csrf.py", line
> 54, in wrapped_view
>     return view_func(*args, **kwargs)
>   File "C:\Python\lib\site-packages\django\views\generic\base.py", line
> 71, in view
>     return self.dispatch(request, *args, **kwargs)
>   File "C:\Python\lib\site-packages\rest_framework\views.py", line 505, in
> dispatch
>     response = self.handle_exception(exc)
>   File "C:\Python\lib\site-packages\rest_framework\views.py", line 465, in
> handle_exception
>     self.raise_uncaught_exception(exc)
>   File "C:\Python\lib\site-packages\rest_framework\views.py", line 476, in
> raise_uncaught_exception
>     raise exc
>   File "C:\Python\lib\site-packages\rest_framework\views.py", line 502, in
> dispatch
>     response = handler(request, *args, **kwargs)
>   File "C:\Python\lib\site-packages\rest_framework\decorators.py", line
> 50, in handler
>     return func(*args, **kwargs)
>   File "C:\app\backend\manage_products\products.py", line 17683, in
> export_report
>     main()
>   File "C:\app\backend\manage_products\products.py", line 17854, in main
>     run_excel(f_path, f_name, sheet_name)
>   File "C:\app\backend\manage_products\products.py", line 17751, in
> run_excel
>     excel = win32.gencache.EnsureDispatch('Excel.Application')
>   File "C:\Python\lib\site-packages\win32com\client\gencache.py", line
> 618, in EnsureDispatch
>     disp = win32com.client.Dispatch(prog_id)
>   File "C:\Python\lib\site-packages\win32com\client\__init__.py", line
> 117, in Dispatch
>     dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,
> userName, clsctx)
>   File "C:\Python\lib\site-packages\win32com\client\dynamic.py", line 106,
> in _GetGoodDispatchAndUserName
>     return (_GetGoodDispatch(IDispatch, clsctx), userName)
>   File "C:\Python\lib\site-packages\win32com\client\dynamic.py", line 88,
> in _GetGoodDispatch
>     IDispatch = pythoncom.CoCreateInstance(
>
> Exception Type: com_error at /export_report
> Exception Value: (-2147221005, 'Invalid class string', None, None)
> "
>
>
> This is the log that we can not rectify even after updating our python
> version and changing container from Linux based environment to Windows
> Based environment.
>
>
> Can you please help us out in figuring this issue out! or can help us in
> suggesting if we can deploy this package in a Linux container. Anything
> works.
>
> Hope to get a positive answer.
>
> Thanks,
> Ankit
> _______________________________________________
> python-win32 mailing list
> python-win32@python.org
> https://mail.python.org/mailman/listinfo/python-win32
>
_______________________________________________
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32

Reply via email to