Create Superuser Issue - Open edX Juniper on AWS EC2 R5.Large

Hi,

Create a superuser in Open edX Juniper is giving the following error:

cd /edx/app/edxapp/edx-platform
sudo -u www-data /edx/bin/python.edxapp ./manage.py lms --settings aws createsuperuser

Error Message:

Traceback (most recent call last):
  File "./manage.py", line 119, in <module>
    startup = importlib.import_module(edx_args.startup)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 665, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/edx/app/edxapp/edx-platform/lms/startup.py", line 10, in <module>
    settings.INSTALLED_APPS  # pylint: disable=pointless-statement
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.5/site-packages/django/conf/__init__.py", line 79, in __getattr__
    self._setup(name)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.5/site-packages/django/conf/__init__.py", line 66, in _setup
    self._wrapped = Settings(settings_module)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.5/site-packages/django/conf/__init__.py", line 157, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'lms.envs.aws'

Please help.

Hello @Azhar_Mateen

The lms.env.aws settings have been dropped in favour of lms.env.production, that’s why the command is failing.

You’ll need to replace --settings aws with --settings production in your manage.py command.

Let me know if you need further assistance. Cheers!

@viadanna thank you for your reply. Now the error message is changed by using the following commands:

cd /edx/app/edxapp/edx-platform
sudo -u www-data /edx/bin/python.edxapp ./manage.py lms --settings production createsuperuser

Error Message:

Traceback (most recent call last):
  File "/edx/app/edxapp/edx-platform/lms/envs/production.py", line 43, in get_env_setting
    return os.environ[setting]
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.5/os.py", line 725, in __getitem__
    raise KeyError(key) from None
KeyError: 'LMS_CFG'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./manage.py", line 119, in <module>
    startup = importlib.import_module(edx_args.startup)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 665, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/edx/app/edxapp/edx-platform/lms/startup.py", line 10, in <module>
    settings.INSTALLED_APPS  # pylint: disable=pointless-statement
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.5/site-packages/django/conf/__init__.py", line 79, in __getattr__
    self._setup(name)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.5/site-packages/django/conf/__init__.py", line 66, in _setup
    self._wrapped = Settings(settings_module)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.5/site-packages/django/conf/__init__.py", line 157, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 665, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/edx/app/edxapp/edx-platform/lms/envs/production.py", line 65, in <module>
    CONFIG_FILE = get_env_setting('LMS_CFG')
  File "/edx/app/edxapp/edx-platform/lms/envs/production.py", line 46, in get_env_setting
    raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured: Set the LMS_CFG env variable

Following are the commands set used to install the Open edX Juniper Release:

sudo apt-get update -y
sudo apt-get upgrade -y
sudo reboot

export OPENEDX_RELEASE=open-release/juniper.master


CONFIG.YML file:

EDXAPP_LMS_BASE: "lms.[mydomain]"
EDXAPP_CMS_BASE: "studio.[mydomain]"



sudo wget https://raw.githubusercontent.com/edx/configuration/$OPENEDX_RELEASE/util/install/ansible-bootstrap.sh -O - | sudo bash

sudo wget https://raw.githubusercontent.com/edx/configuration/$OPENEDX_RELEASE/util/install/generate-passwords.sh -O - | bash

sudo wget https://raw.githubusercontent.com/edx/configuration/$OPENEDX_RELEASE/util/install/native.sh -O - | bash

The installation was successful without any errors. LMS and Studio are appearing correctly.

That error stems from missing environment variables, present in /edx/app/edxapp/edxapp_env.

Your easiest way around here is loading those variables beforehand:

$ source /edx/app/edxapp/edxapp_env

An alternative is changing to the edxapp user to run these commands, as the environment is loaded by bash:

$ sudo -Hsu edxapp bash
$ cd /edx/app/edxapp/edx-platform
$ source ../venvs/edxapp/bin/activate
$ python manage.py lms --settings production createsuperuser
3 Likes

Here is the file content of /edx/app/edxapp/edxapp_env

# This file is created and updated by ansible, edit at your peril
export LANG="en_US.UTF-8"
export SKIP_WS_MIGRATIONS="1"
export CONFIG_ROOT="/edx/app/edxapp"
export STUDIO_CFG="/edx/etc/studio.yml"
export REVISION_CFG="/edx/etc/revisions.yml"
export PATH="/edx/app/edxapp/venvs/edxapp/bin:/edx/app/edxapp/edx-platform/bin:/edx/app/edxapp/edx-platform/node_modules/.bin:/edx/app/edxapp/nodeenvs/edxapp/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"             $
export EDX_PLATFORM_SETTINGS="production"
export LMS_CFG="/edx/etc/lms.yml"
export NO_PREREQ_INSTALL="1"
export BOTO_CONFIG="/edx/app/edxapp/.boto"

Error Message:

Traceback (most recent call last):
  File "/edx/app/edxapp/edx-platform/lms/envs/production.py", line 43, in get_env_setting
    return os.environ[setting]
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.5/os.py", line 725, in __getitem__
    raise KeyError(key) from None
KeyError: 'LMS_CFG'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 119, in <module>
    startup = importlib.import_module(edx_args.startup)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 665, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/edx/app/edxapp/edx-platform/lms/startup.py", line 10, in <module>
    settings.INSTALLED_APPS  # pylint: disable=pointless-statement
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.5/site-packages/django/conf/__init__.py", line 79, in __getattr__
    self._setup(name)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.5/site-packages/django/conf/__init__.py", line 66, in _setup
    self._wrapped = Settings(settings_module)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.5/site-packages/django/conf/__init__.py", line 157, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 665, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/edx/app/edxapp/edx-platform/lms/envs/production.py", line 65, in <module>
    CONFIG_FILE = get_env_setting('LMS_CFG')
  File "/edx/app/edxapp/edx-platform/lms/envs/production.py", line 46, in get_env_setting
    raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured: Set the LMS_CFG env variable

However, following command set succeded to create a superuser:

CREATE SUPERUSER:

sudo su edxapp -s /bin/bash
source edxapp_env
cd
/edx/bin/python.edxapp /edx/bin/manage.edxapp lms manage_user username email@example.com --staff --superuser --settings=production

exit


CHANGE PASSWORD:

cd /edx/app/edxapp/edx-platform
./manage.py lms --settings production changepassword username 

Many thanks for reaching a solution.

1 Like

Hello @Azhar_Mateen , I have installed open edx juniper.master release successfully.And also your solution has worked for me as well. My problem is on creating another superuser and changing password.

sudo -Hsu edxapp bash
This command is asking me for password:
[sudo] password for edxapp:

I’ve created a super user first but didn’t change the password , How do I manage to change password or acess password for edxapp?
Thanks in advance for your help.

When I run these commands

cd /edx/app/edxapp/edx-platform
./manage.py lms --settings production changepassword username

I’m getting this error

Traceback (most recent call last):
File “./manage.py”, line 17, in
log_python_warnings()
File “/edx/app/edxapp/edx-platform/openedx/core/lib/logsettings.py”, line 125, in log_python_warnings
warnings.filterwarnings(‘ignore’, ‘.unclosed.’, category=ResourceWarning)
NameError: global name ‘ResourceWarning’ is not defined

Hi @Natnael,

It looks like you are trying to run this command outside of the virtualenv. You should be able to do it like this:

cd /edx/app/edxapp/
source edxapp_env
/edx/bin/python.edxapp /edx/bin/manage.edxapp lms changepassword username --settings production

@Agrendalath
Thanks!