GibbsConsulting / django-plotly-dash

Expose plotly dash apps as django tags
MIT License
548 stars 124 forks source link

DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses #472

Open samarthsarin opened 1 year ago

samarthsarin commented 1 year ago

I have install the latest version of django_plotly_dash library. When I add 'django_plotly_dash.apps.DjangoPlotlyDashConfig' in INSTALLED_APPS the following error shows up and my django app doesn't start.

DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses

Please help me solve this issue.

delsim commented 1 year ago

@samarthsarin is there any more to the error message?

In particular, it would be helpful to know what module contains the import statement leading to this warning.

However, a DeprecationWarning is just that - a warning - and on its own would not (usually!) cause program execution to halt.

samarthsarin commented 1 year ago

python .\source\manage.py runserver Watching for file changes with StatReloader Exception in thread django-main-thread: Traceback (most recent call last): File "C:\Users\ssarin\Anaconda3\lib\threading.py", line 932, in _bootstrap_inner self.run() File "C:\Users\ssarin\Anaconda3\lib\threading.py", line 870, in run self._target(*self._args, self._kwargs) File "C:\Users\ssarin\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper fn(*args, *kwargs) File "C:\Users\ssarin\Anaconda3\lib\site-packages\django\core\management\commands\runserver.py", line 125, in inner_run autoreload.raise_last_exception() File "C:\Users\ssarin\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 87, in raise_last_exception raise _exception[1] File "C:\Users\ssarin\Anaconda3\lib\site-packages\django\core\management__init__.py", line 394, in execute autoreload.check_errors(django.setup)() File "C:\Users\ssarin\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper fn(args, kwargs) File "C:\Users\ssarin\Anaconda3\lib\site-packages\django__init.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "C:\Users\ssarin\Anaconda3\lib\site-packages\django\apps\registry.py", line 91, in populate app_config = AppConfig.create(entry) File "C:\Users\ssarin\Anaconda3\lib\site-packages\django\apps\config.py", line 178, in create mod = import_module(mod_path) File "C:\Users\ssarin\Anaconda3\lib\importlib__init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 961, in _find_and_load_unlocked File "", line 219, in _call_with_frames_removed File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 975, in _find_and_load_unlocked File "", line 671, in _load_unlocked File "", line 783, in exec_module File "", line 219, in _call_with_frames_removed File "C:\Users\ssarin\Anaconda3\lib\site-packages\django_plotly_dash\init.py", line 31, in from .dash_wrapper import DjangoDash File "C:\Users\ssarin\Anaconda3\lib\site-packages\django_plotly_dash\dash_wrapper.py", line 33, in import dash File "C:\Users\ssarin\Anaconda3\lib\site-packages\dash\init.py", line 36, in from .dash import ( # noqa: F401,E402 File "C:\Users\ssarin\Anaconda3\lib\site-packages\dash\dash.py", line 22, in from pkg_resources import get_distribution, parse_version File "C:\Users\ssarin\Anaconda3\lib\site-packages\pkg_resources\init.py", line 73, in from pkg_resources.extern import appdirs File "", line 991, in _find_and_load File "", line 975, in _find_and_load_unlocked File "", line 655, in _load_unlocked File "", line 618, in _load_backward_compatible File "C:\Users\ssarin\Anaconda3\lib\site-packages\pkg_resources\extern\init__.py", line 43, in load_module import(extant) File "C:\Users\ssarin\Anaconda3\lib\site-packages\pkg_resources_vendor\appdirs.py", line 560, in import win32com.shell File "C:\Users\ssarin\Anaconda3\lib\site-packages\win32com\init__.py", line 6, in import pythoncom File "C:\Users\ssarin\Anaconda3\lib\site-packages\pythoncom.py", line 2, in import pywintypes File "C:\Users\ssarin\Anaconda3\lib\site-packages\win32\lib\pywintypes.py", line 2, in import imp, sys, os File "C:\Users\ssarin\Anaconda3\lib\imp.py", line 31, in warnings.warn("the imp module is deprecated in favour of importlib; " DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses

delsim commented 1 year ago

So that warning is arising from some windows-specific functionality that in turn is being loaded by some modules that are being loaded by Dash - its not coming from django-plotly-dash.

As a first step, I would check that python and Dash are correctly installed, and then try importing each of the packages in turn directly from a python REPL prompt.

samarthsarin commented 1 year ago

Hi,

Thank you for the response. Everything independently seems to be working fine and imports are successful. I have tried it on different machines as well as re installing almost all libraries again. Still the same error persists.

On Sat, Aug 12, 2023, 04:35 Mark Gibbs @.***> wrote:

So that warning is arising from some windows-specific functionality that in turn is being loaded by some modules that are being loaded by Dash - its not coming from django-plotly-dash.

As a first step, I would check that python and Dash are correctly installed, and then try importing each of the packages in turn directly from a python REPL prompt.

— Reply to this email directly, view it on GitHub https://github.com/GibbsConsulting/django-plotly-dash/issues/472#issuecomment-1675501676, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJSHET7FWB74F4SQF77QRCTXU23E5ANCNFSM6AAAAAA3KAET4M . You are receiving this because you were mentioned.Message ID: @.***>

delsim commented 1 year ago

Can you do the following:

  1. launch python
  2. enter import django and press return
  3. enter django.__version__ and press return
  4. enter import dash and press return
  5. enter dash.__version__ and press return

and then report what responses you get for each step?