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

No module named 'production_settings' #5

Closed
flashfingaz opened this issue Apr 16, 2018 · 7 comments
Closed

No module named 'production_settings' #5

flashfingaz opened this issue Apr 16, 2018 · 7 comments

Comments

@flashfingaz
Copy link

Hi,

I'm trying to deploy this plugin inside a docker installation via the official instructions but it fails with 'No module named 'production_settings'. I'm not sure whats the root cause of this problem as I did not find any import directive for 'production_settings'.

So far this seems only to affect the cashpayment plugin (tried with pretix-pages, pretix-passbook - could build both of them without this problem)

Maybe I'm just missing something here...

Any help would be great. Thanks in advance!

my Dockerfile looks like this:

FROM pretix/standalone:stable
USER root
RUN pip3 install pretix-cashpayment
USER pretixuser
RUN cd /pretix/src && make production

build output as follows:

Sending build context to Docker daemon  2.048kB
Step 1/5 : FROM pretix/standalone:stable
 ---> 6b6af0667f30
Step 2/5 : USER root
 ---> Using cache
 ---> 9dbd8e9aa9ef
Step 3/5 : RUN pip3 install pretix-cashpayment
 ---> Running in 9475f0bd7b07
Collecting pretix-cashpayment
  Downloading https://files.pythonhosted.org/packages/85/15/43092bc771fe1a616dde0505e322e224efe93eb2812d0ec8616b18c6d32f/pretix-cashpayment-1.0.2.tar.gz
Collecting segno (from pretix-cashpayment)
  Downloading https://files.pythonhosted.org/packages/94/5b/619a63cd22f82d0add2be1f5486736f2e5e871d6414976250c009e3753ba/segno-0.2.7-py2.py3-none-any.whl (67kB)
Building wheels for collected packages: pretix-cashpayment
  Running setup.py bdist_wheel for pretix-cashpayment: started
  Running setup.py bdist_wheel for pretix-cashpayment: finished with status 'error'
  Complete output from command /usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-j0iilo25/pretix-cashpayment/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmpsf2qe49dpip-wheel- --python-tag cp36:
  running bdist_wheel
  running build
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-build-j0iilo25/pretix-cashpayment/setup.py", line 43, in <module>
      """,
    File "/usr/local/lib/python3.6/site-packages/setuptools/__init__.py", line 129, in setup
      return distutils.core.setup(**attrs)
    File "/usr/local/lib/python3.6/distutils/core.py", line 148, in setup
      dist.run_commands()
    File "/usr/local/lib/python3.6/distutils/dist.py", line 955, in run_commands
      self.run_command(cmd)
    File "/usr/local/lib/python3.6/distutils/dist.py", line 974, in run_command
      cmd_obj.run()
    File "/usr/local/lib/python3.6/site-packages/wheel/bdist_wheel.py", line 204, in run
      self.run_command('build')
    File "/usr/local/lib/python3.6/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/usr/local/lib/python3.6/distutils/dist.py", line 974, in run_command
      cmd_obj.run()
    File "/tmp/pip-build-j0iilo25/pretix-cashpayment/setup.py", line 17, in run
      management.call_command('compilemessages', verbosity=1, interactive=False)
    File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 131, in call_command
      return command.execute(*args, **defaults)
    File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 330, in execute
      output = self.handle(*args, **options)
    File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/compilemessages.py", line 67, in handle
      basedirs.extend(upath(path) for path in settings.LOCALE_PATHS)
    File "/usr/local/lib/python3.6/site-packages/django/conf/__init__.py", line 56, in __getattr__
      self._setup(name)
    File "/usr/local/lib/python3.6/site-packages/django/conf/__init__.py", line 41, in _setup
      self._wrapped = Settings(settings_module)
    File "/usr/local/lib/python3.6/site-packages/django/conf/__init__.py", line 110, in __init__
      mod = importlib.import_module(self.SETTINGS_MODULE)
    File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File "<frozen importlib._bootstrap>", line 994, in _gcd_import
    File "<frozen importlib._bootstrap>", line 971, in _find_and_load
    File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
  ModuleNotFoundError: No module named 'production_settings'
  ----------------------------------------
  Failed building wheel for pretix-cashpayment
  Running setup.py clean for pretix-cashpayment
Failed to build pretix-cashpayment
Installing collected packages: segno, pretix-cashpayment
  Running setup.py install for pretix-cashpayment: started
    Running setup.py install for pretix-cashpayment: finished with status 'error'
    Complete output from command /usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-j0iilo25/pretix-cashpayment/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-szsl5611-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-j0iilo25/pretix-cashpayment/setup.py", line 43, in <module>
        """,
      File "/usr/local/lib/python3.6/site-packages/setuptools/__init__.py", line 129, in setup
        return distutils.core.setup(**attrs)
      File "/usr/local/lib/python3.6/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/usr/local/lib/python3.6/distutils/dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "/usr/local/lib/python3.6/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/usr/local/lib/python3.6/site-packages/setuptools/command/install.py", line 61, in run
        return orig.install.run(self)
      File "/usr/local/lib/python3.6/distutils/command/install.py", line 545, in run
        self.run_command('build')
      File "/usr/local/lib/python3.6/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/local/lib/python3.6/distutils/dist.py", line 974, in run_command
        cmd_obj.run()
      File "/tmp/pip-build-j0iilo25/pretix-cashpayment/setup.py", line 17, in run
        management.call_command('compilemessages', verbosity=1, interactive=False)
      File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 131, in call_command
        return command.execute(*args, **defaults)
      File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 330, in execute
        output = self.handle(*args, **options)
      File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/compilemessages.py", line 67, in handle
        basedirs.extend(upath(path) for path in settings.LOCALE_PATHS)
      File "/usr/local/lib/python3.6/site-packages/django/conf/__init__.py", line 56, in __getattr__
        self._setup(name)
      File "/usr/local/lib/python3.6/site-packages/django/conf/__init__.py", line 41, in _setup
        self._wrapped = Settings(settings_module)
      File "/usr/local/lib/python3.6/site-packages/django/conf/__init__.py", line 110, in __init__
        mod = importlib.import_module(self.SETTINGS_MODULE)
      File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 994, in _gcd_import
      File "<frozen importlib._bootstrap>", line 971, in _find_and_load
      File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
    ModuleNotFoundError: No module named 'production_settings'
    ----------------------------------------
Command "/usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-j0iilo25/pretix-cashpayment/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-szsl5611-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-j0iilo25/pretix-cashpayment/
You are using pip version 9.0.1, however version 10.0.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
The command '/bin/sh -c pip3 install pretix-cashpayment' returned a non-zero code: 1

@pc-coholic
Copy link
Owner

I am not really sure, what this might be caused by... I'll have a look at it and try to figure it out.

Also, paging @raphaelm, the almighty pretix-god, for further insights, as the only place I could find production_settings is in https://github.com/pretix/pretix/blob/master/deployment/docker/production_settings.py ;-)

@raphaelm
Copy link
Contributor

My wild guess would be that you need to chdir before you pip install in your dockerfile:

FROM pretix/standalone:stable
USER root
RUN cd /pretix/src && pip3 install pretix-cashpayment
USER pretixuser
RUN cd /pretix/src && make production

Haven't tested it, though.

@flashfingaz
Copy link
Author

I tried as @raphaelm suggested to cd into /pretix/src via Dockerfile and also tried to add it to PATH but the situation remains. I will try around some more as it seems PATH is not modified permanently in the docker build env.

current Dockerfile:

FROM pretix/standalone:stable
USER root
RUN export PATH=$PATH:/pretix/src && pip3 install pretix-cashpayment
USER pretixuser
RUN cd /pretix/src && make production

@pc-coholic
Copy link
Owner

Please try this:

FROM pretix/standalone:stable
USER root
ENV DJANGO_SETTINGS_MODULE=
RUN pip3 install pretix-cashpayment
ENV DJANGO_SETTINGS_MODULE=production_settings
USER pretixuser
RUN cd /pretix/src && make production

@flashfingaz
Copy link
Author

PYTHONPATH did the trick, the following Dockerfile actually worked for me to build the plugin:

FROM pretix/standalone:stable
USER root
RUN export PYTHONPATH=$PYTHONPATH:/pretix/src && pip3 install pretix-cashpayment
USER pretixuser
RUN cd /pretix/src && make production

@flashfingaz
Copy link
Author

@pc-coholic just now saw your answer. tried it and it works as well.

Thx guys, your fast input made this horrible problem dissolve in a flash :) 👍

@trysten
Copy link

trysten commented Feb 11, 2021

I ran into this issue. I think the root cause is lack of DJANGO_SETTINGS_MODULE. I specified it as in the docs and it worked.

RUN DJANGO_SETTINGS_MODULE=pretix.settings pip install whatever

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants