Any ideas how to get to work manage.py?

Every time I need to run some command with manage.py I get an error message, any idea how to fix it?

1. I try to run:

aprendetecho@aprende:/edx/app/edxapp/edx-platform$ sudo -u www-data /edx/bin/python.edxapp ./manage.py lms --settings production help

And I get:

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

2. Then I tried this one:

aprendetecho@aprende:/edx/app/edxapp/edx-platform$ ./manage.py lms manage_user kike.ramirez kike.ramirez@techo.org --staff --superuser --settings=devstack

And got these:

Traceback (most recent call last):
  File "./manage.py", line 17, in <module>
    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

I have no idea what to do to fix it? Some help please!

1 Like

This could be due to requirements not being installed correctly. Can you try reinstalling the python requirements and testing again?

Thanks @pkulkark, just one more question:

How can I do that without doing it worng?

Have tried this?

sudo -H -u edxapp bash
cd
source edxapp_env
source venvs/edxapp/bin/activate
cd edx-platform
python manage.py

Thanks @sambapete I guess that actually worked:

aprendetecho@aprende:~$ sudo -H -u edxapp bash
edxapp@aprende:/home/aprendetecho$ cd
edxapp@aprende:~$ source edxapp_env
edxapp@aprende:~$ source venvs/edxapp/bin/activate
(edxapp) edxapp@aprende:~$ cd edx-platform
(edxapp) edxapp@aprende:~/edx-platform$ python manage.py
Traceback (most recent call last):
  File "manage.py", line 98, in <module>
    edx_args, django_args = parse_args()
  File "manage.py", line 90, in parse_args
    if edx_args.help:
AttributeError: 'Namespace' object has no attribute 'help'
(edxapp) edxapp@aprende:~/edx-platform$ python manage.py --help
usage: manage.py [-h] {lms,cms} ...

optional arguments:
  -h, --help  show this help message and exit

system:
  edX service to run

  {lms,cms}
    lms       Learning Management System
    cms       Studio
(edxapp) edxapp@aprende:~/edx-platform$

Perhaps still I don’t fully understand this but I already managed to create super users and so.

Thanks again!

1 Like