Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python: ModuleNotFoundError: No module named 'memcache' #2728

Closed
Tracked by #2776
NickMous opened this issue Jan 23, 2024 · 16 comments · Fixed by #2778
Closed
Tracked by #2776

Python: ModuleNotFoundError: No module named 'memcache' #2728

NickMous opened this issue Jan 23, 2024 · 16 comments · Fixed by #2778

Comments

@NickMous
Copy link

Self-Hosted Version

24.1.0

CPU Architecture

x86_64

Docker Version

25.0.0

Docker Compose Version

2.24.1

Steps to Reproduce

  1. Have sentry self-hosted previous version installed
  2. do git pull
  3. run ./install.sh

Expected Result

A working sentry

Actual Result

Screenshot_20240123_095114
Screenshot_20240123_095302
While upgrading it already stated that it couldn't do anything with redis, because of memcached. This was only a warning, so it went through. But now it also shows up in the logs of the sentry web runner, and I get a 502 bad gateway.

Event ID

No response

@lukasleitsch
Copy link

A workaround until the issue is fixed in the nightly image.

SENTRY_IMAGE=getsentry/sentry:24.1.0 ./install.sh

@NickMous
Copy link
Author

Thanks! I switched to the 24.1.0 label for the time being :)

@aldy505
Copy link
Collaborator

aldy505 commented Jan 24, 2024

Hi @NickMous can you confirm that the solution on this works? #2722

@NickMous
Copy link
Author

Hi @aldy505 ! I unfortunately was sick, but now I've taken the time for testing this, and this is what I now have:
When pulling the latest from master there are errors still remaining about memcache, but now mainly AttributeError: module 'django.core.cache.backends.memcached' has no attribute 'MemcachedCache'`.
So far with replacing the image version from nightly to 24.1.0 I get another error that the app_bootstrap_initializeMain is not found. I'll try to rerun the install.sh, I'll get back in a sec

@getsantry getsantry bot moved this from Waiting for: Community to Waiting for: Product Owner in GitHub Issues with 👀 2 Jan 26, 2024
@NickMous
Copy link
Author

For some reason running without the tag to give y'all insight for errors and manually saying yes, the install worked now and it's up and running. So it has not been fixed yet on master/nightly, but master/SENTRY_IMAGE=getsentry/sentry:24.1.0 works

@bobvandevijver
Copy link

bobvandevijver commented Jan 27, 2024

I believe I hit this issue when upgrading from 24.1.0 to 24.1.1.

django.core.cache.backends.base.InvalidCacheBackendError: Could not find backend 'django.core.cache.backends.memcached.MemcachedCache': Module "django.core.cache.backends.memcached" does not define a "MemcachedCache" attribute/class
Error in install/set-up-and-migrate-database.sh:12.

Full log here: sentry_install_log-2024-01-27_09-32-14.txt

Reverting to 24.1.0 allows me to get Sentry back up and running again.

@asottile-sentry
Copy link
Member

you'll want to change your configuration to use the pymemcache backend -- django no longer ships a backend for python-memcached https://docs.djangoproject.com/en/4.2/topics/cache/#memcached

@csvan
Copy link

csvan commented Jan 27, 2024

@bobvandevijver update your sentry.conf.py to contain this for CACHES:

CACHES = {
    "default": {
        "BACKEND": "django.core.cache.backends.memcached.PyMemcacheCache",
        "LOCATION": ["memcached:11211"],
        "TIMEOUT": 3600,
        "OPTIONS": {"ignore_exc": True}
    }
}

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 2 Jan 27, 2024
@bobvandevijver
Copy link

@asottile-sentry / @csvan Thank you for pointing me to that, I always forget to check these config files for changes! It is now working as it should :)

@msschl
Copy link

msschl commented Jan 29, 2024

@bobvandevijver update your sentry.conf.py to contain this for CACHES:

CACHES = {
    "default": {
        "BACKEND": "django.core.cache.backends.memcached.PyMemcacheCache",
        "LOCATION": ["memcached:11211"],
        "TIMEOUT": 3600,
        "OPTIONS": {"ignore_exc": True}
    }
}

This worked for me when upgrading from 24.1.0 to 24.1.1.

@chadwhitacre
Copy link
Member

We at least need a note in the release notes for whatever version introduced this configuration change.

It seems, though, like we should add something under install.sh to rewrite sentry.conf.py automatically.

@hubertdeng123
Copy link
Member

We at least need a note in the release notes for whatever version introduced this configuration change.

This is done already here: https://github.com/getsentry/self-hosted/releases/tag/24.1.1

It seems, though, like we should add something under install.sh to rewrite sentry.conf.py automatically.

Agreed here

@bobvandevijver
Copy link

@hubertdeng123 But that wasn't there when the release was made (and therefor not included in the Github notification I got). But good to see it is there now.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 2 Jan 29, 2024
@chadwhitacre
Copy link
Member

We should get something in to fix up sentry.conf.py automatically asap, and definitely before shipping 24.2.0 (#2714). I propose we rewrite the conf file automatically if it contains the default value, and report on what we did (whether rewrite or skip).

@Apollon77
Copy link

Apollon77 commented Feb 7, 2024

PS: Also the release note wording "you may need to" do not really imply that it is a thing you need to do :-)

( I also run into it while upgrading to 24.1.1)

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 2 Feb 7, 2024
@clayvan
Copy link

clayvan commented Feb 7, 2024

Am I the only one who still experiences this even with the updated config?

Trying to deploy 24.1.1 with this config (note my memcached service name is different on purpose)

      CACHES = {
        "default": {
          "BACKEND": "django.core.cache.backends.memcached.PyMemcacheCache",
          "LOCATION": ["sentry-memcached:11211"],
          "TIMEOUT": 3600,
          "OPTIONS": {"ignore_exc": True}
        }
      }

and I still receive:

ModuleNotFoundError: No module named 'memcache'

@hubertdeng123 hubertdeng123 mentioned this issue Feb 8, 2024
20 tasks
@github-actions github-actions bot locked and limited conversation to collaborators Feb 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Archived in project
Archived in project
Development

Successfully merging a pull request may close this issue.

12 participants