0

am new to python and django

I am trying to build a small python django application on my local windows laptop.

i am not able to underlying tables required for my Django project as when i run "python manage.py syncdb" i get the below error

` Error :django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'. Did you install mysqlclient or MySQL-python? '

And when i try running "pip install mysqlclient" i get the below error

'error: Microsoft Visual C++ 10.0 is required. Get it with "Microsoft Windows SDK 7.1": www.microsoft.com/download/details.aspx?id=8279'

I am stuck in this step and not able to find any leads. can someone suggest any workaround

DJ RAXITH
  • 13
  • 2
  • can you try this https://stackoverflow.com/a/25569814/7261317 – Robert Aug 30 '17 at 12:14
  • http://www.marinamele.com/taskbuster-django-tutorial/install-and-configure-mysql-for-django – Robert Aug 30 '17 at 12:15
  • If you're trying to install on Windows, then Robert's advice above might not help - however, there are binary packages available for MySQL-python and mysqlclient at http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python . – bouteillebleu Aug 30 '17 at 12:18
  • What is unclear about the bottom error messages instructions? – Sayse Aug 30 '17 at 12:19
  • Are you using a virtual environment? If so, did you activate it before running the "pip" command and before running "python manage.py syncdb" ? – Andre Barbosa Aug 30 '17 at 12:22
  • http://www.swegler.com/becky/blog/2011/09/14/python-django-mysql-on-windows-7-part-5-installing-mysql/ – Robert Aug 30 '17 at 12:28

1 Answers1

2

By default Django is configured to use Sqlite database. See settings.py file:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

You have it configured to use MySQL database:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'DATABASE_NAME',
        'USER': 'DB_USERNAME',
        'PASSWORD': 'DB_PASSWORD',
        'HOST': '127.0.0.1',
        'PORT': '3306'
    }
}

If it's a small test project, I would recommend you to switch back to Sqlite, but if you intend to run your project later in production using MySQL, then better use MySQL in development process.

Install:

NullIsNot0
  • 401
  • 5
  • 7
  • thanks @nullsnot0 i am facing a new error. "_mysql.c(29) : fatal error C1083: Cannot open include file: 'my_config.h': No such file or directory error: command '"c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\amd64\cl.exe"' failed with exit status 2" – DJ RAXITH Aug 30 '17 at 15:45
  • Sorry, I have no Windows computer to test mysqlclient installation, but you could try checking this answer: [https://stackoverflow.com/a/31077052/8433375](https://stackoverflow.com/a/31077052/8433375), but before check your python version with `pyphon --version` to be shore which version of mysqlclient to choose. Also check `pip --version` to be shore pip is using right python (if you have multiple versions installed on system) – NullIsNot0 Aug 30 '17 at 17:29