Install script Django - Missing command python

I buy Virtulamin 6.14 Pro version for running Django.

Tried to install on virtual serveris with Available Scripts -> Django 1.9.7 and I get this error message.

This script cannot be installed, as this virtual server does not meet its requirements : The python command is not installed, Could not work out Python version : sh: 1: --version: not found , Missing command python

Tried to google this problem but at the moment without any luck.

Status: 
Fixed (pending)
Virtualmin version: 
6.14
Webmin version: 
1.962

Comments

Ilia's picture
Submitted by Ilia on Tue, 01/19/2021 - 03:47

Hi,

The simple work-around would be is to go to Virtualmin Configuration and set default Python command to python3 in Advanced Options.

Ilia's picture
Submitted by Ilia on Tue, 01/19/2021 - 04:02

Next Virtualmin release will have it working the right way out of the box.

Thanks for reporting.

When I start to install script then get this error:

Reading package lists...
Building dependency tree...
Reading state information...
Package python-mysqldb is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'python-mysqldb' has no installation candidate

I fix with

sudo apt-get install python3-mysqldb

but then:

Now installing Django version 1.9.7 ..

    DB initialization install failed :

    Traceback (most recent call last):
      File "manage.py", line 10, in 
        execute_from_command_line(sys.argv)
      File "/home/moskovskaya/public_html/lib/python/Django-1.9.7-py3.8.egg/django/core/management/__init__.py", line 353, in execute_from_command_line
        utility.execute()
      File "/home/moskovskaya/public_html/lib/python/Django-1.9.7-py3.8.egg/django/core/management/__init__.py", line 327, in execute
        django.setup()
      File "/home/moskovskaya/public_html/lib/python/Django-1.9.7-py3.8.egg/django/__init__.py", line 18, in setup
        apps.populate(settings.INSTALLED_APPS)
      File "/home/moskovskaya/public_html/lib/python/Django-1.9.7-py3.8.egg/django/apps/registry.py", line 108, in populate
        app_config.import_models(all_models)
      File "/home/moskovskaya/public_html/lib/python/Django-1.9.7-py3.8.egg/django/apps/config.py", line 202, in import_models
        self.models_module = import_module(models_module_name)
      File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "", line 1014, in _gcd_import
      File "", line 991, in _find_and_load
      File "", line 975, in _find_and_load_unlocked
      File "", line 671, in _load_unlocked
      File "", line 783, in exec_module
      File "", line 219, in _call_with_frames_removed
      File "/home/moskovskaya/public_html/lib/python/Django-1.9.7-py3.8.egg/django/contrib/auth/models.py", line 4, in 
        from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
      File "/home/moskovskaya/public_html/lib/python/Django-1.9.7-py3.8.egg/django/contrib/auth/base_user.py", line 49, in 
        class AbstractBaseUser(models.Model):
    RuntimeError: __class__ not set defining 'AbstractBaseUser' as . Was __classcell__ propagated to type.__new__?
Ilia's picture
Submitted by Ilia on Tue, 01/19/2021 - 06:04

Okay, there were few bugs. It will be fixed for the next release, meanwhile run:

curl https://raw.githubusercontent.com/virtualmin/virtualmin-gpl/master/scripts-lib.pl -o /usr/share/webmin/virtual-server/scripts-lib.pl

.. and you would need to update Django install script and make sure that you're installing latest 3.1.5 which actually works:

curl https://raw.githubusercontent.com/virtualmin/virtualmin-gpl/master/scripts/django.pl -o /usr/share/webmin/virtual-server/scripts/django.pl

Restart Webmin afterwards and enjoy your ride. :--)

/etc/webmin/restart

I ran into the same problem and after following the above directions I encountered another problem:

public_html/zunzun/lib/python/Django-3.1.7-py3.7.egg/django/db/backends/mysql/introspection.py", line 27, in DatabaseIntrospection
    FIELD_TYPE.JSON: 'JSONField',
AttributeError: module 'MySQLdb.constants.FIELD_TYPE' has no attribute 'JSON'
Ilia's picture
Submitted by Ilia on Tue, 02/23/2021 - 02:16

FIELD_TYPE.JSON: 'JSONField', AttributeError: module 'MySQLdb.constants.FIELD_TYPE' has no attribute 'JSON'

It doesn't seem as Virtualmin issue to me.

I won't ask why you're still using Django 1.9 but I noticed that in your posts you have:

"Now installing Django version 1.9.7"

"python/Django-1.9.7-py3.8.egg"

"python/Django-3.1.7-py3.7.egg"

You can't mix and match Django ~ python versions. I recommend using "virtualenv" to compartmentalise your packages.

FWIW you shouldnt be putting your Django app inside "public_html". One bad config and Apache will be returning your whole file directory to the browser.