rq / django-rq

A simple app that provides django integration for RQ (Redis Queue)
MIT License
1.81k stars 286 forks source link

ModuleNotFoundError: No module named 'resource' #584

Closed DanielHGimenez closed 1 year ago

DanielHGimenez commented 1 year ago

I installed django-rq in my project and I did the setup, but when I run my project with the command python manage.py runserver I receive the following error:

Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "C:\Python311\Lib\threading.py", line 1038, in _bootstrap_inner
    self.run()
  File "C:\Python311\Lib\threading.py", line 975, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Python311\Lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "C:\Python311\Lib\site-packages\django\core\management\commands\runserver.py", line 125, in inner_run
    autoreload.raise_last_exception()
  File "C:\Python311\Lib\site-packages\django\utils\autoreload.py", line 87, in raise_last_exception
    raise _exception[1]
  File "C:\Python311\Lib\site-packages\django\core\management\__init__.py", line 394, in execute
    autoreload.check_errors(django.setup)()
  File "C:\Python311\Lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "C:\Python311\Lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\Python311\Lib\site-packages\django\apps\registry.py", line 91, in populate
    app_config = AppConfig.create(entry)
                 ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\site-packages\django\apps\config.py", line 193, in create
    import_module(entry)
  File "C:\Python311\Lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Python311\Lib\site-packages\django_rq\__init__.py", line 3, in <module>
    from .decorators import job
  File "C:\Python311\Lib\site-packages\django_rq\decorators.py", line 1, in <module>
    from rq.decorators import job as _rq_job
  File "C:\Python311\Lib\site-packages\rq\__init__.py", line 7, in <module>
    from .worker import SimpleWorker, Worker
  File "C:\Python311\Lib\site-packages\rq\worker.py", line 6, in <module>
    import resource
ModuleNotFoundError: No module named 'resource'

I'm working on Windows 10 with Python 3.10.11

some1ataplace commented 1 year ago

One possible solution is to install the psutil package, which provides cross-platform access to many system functionalities, including the resource module. You can install it by running the following command in your terminal or command prompt:

pip install psutil

gmjosack commented 1 year ago

This is actually an issue with the rq package, not django-rq but found this while searching for the issue. It looks like it was fixed in rq/rq#948 so hopefully they'll cut a new release soon. For now I'm just using rq 1.12 until i can test on windows again.