0

Trying to python manage.py syncdb but it gives me an error. Similar to a lot of other questions on here, but the solutions provided do not solve the error after I install them.

My settings.py file inside my project directory

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'network',
        'USER': 'root',
        'PASSWORD': 'mypass',
        'HOST': '', #EMPTY FOR LOCALHOST
        'PORT': '3307', #Empty by default
    }
}

I am using Windows 7, Python 3.4 (I heard was not compatible with install MySQL-python so instead I downloaded mysqlclient 1.3.6).

When I ran easy_install mysql-python it results in

_mysql.c(42) : fatal error C1083: Cannot open include file: 'config-win.h': No such file or directory
error: Setup script exited with error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\BIN\\cl.exe'
failed with exit status 2

Similarly it asks for config-win.h when running pip install mysql-python, along with a scary error

Command "D:\Users\Python\python.EXE -c "import setuptools, tokenize;__file__='C:\\Users\\AppData\\Local\\T
emp\\pip-build-w7q9kjxi\\mysql-python\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('
\r\n', '\n'), __file__, 'exec'))" install --record C:\Users\AppData\Local\Temp\pip-u982sugf-record\install-record.t
xt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\AppData\Local\Temp\pip-build
-w7q9kjxi\mysql-python

I'm pretty confused about this. The tutorial I've been looking at strays from me here, and I have no idea what to do with a WHL of mysqlclient.

Things I've tried already:

  • easy_install Distribute works but does not change anything

  • python manage.py syncdb no module named 'MySQLdb'

  • apt-get install python-mysqldb term 'apt-get' not recognized at all.

Please help with this beginner question, thanks for your time, if more info is needed I'd be happy to provide.

Script Kitty
  • 1,737
  • 5
  • 27
  • 47
  • What version of Django? – nivix zixer May 23 '15 at 02:52
  • I think 1.8.1 from recently – Script Kitty May 23 '15 at 02:57
  • You're clearly looking at some out-of-date resources. You almost never want to use `easy_install`. And you _definitely_ don't want `distribute`; that's an obsolete project that has been replaced by `setuptools`. – abarnert May 23 '15 at 02:57
  • Anyway, your actual problem smells like the `vcvarsall` problem configuring Python to use Visual Studio; do a search for `[python] vcvarsall` and you should find an answer. – abarnert May 23 '15 at 02:59

2 Answers2

3

Without Visual Studio, you'll need a binary installer for the right Python version and architecture. The easiest is probably to get both 32- and 64- bit packages for the installed Python version and install them both.

  • This might be a stupid question, but if I have Microsoft Visual Studio 2010 in a different directory can it use that? I'll try the binary hang on. – Script Kitty May 23 '15 at 02:49
  • Yes, as long as the right environment variables are set (https://methedrine.org/2014/11/19/using-setuptools-with-the-microsoft-visual-c-compiler-for-python-2-7/comment-page-1/) , the Python installer should find the compiler. –  May 23 '15 at 02:51
  • I have `mysqlclient-1.3.6-cp34-none-win_amd64.whl` and now `MySQL_python-1.2.5-cp27-none-win_amd64.whl` in my Python directory let me rerun pip – Script Kitty May 23 '15 at 02:52
  • It should be either that one or the win32 one, yes. –  May 23 '15 at 02:53
  • Unfortunately it doesn't change anything and that may be some stupid mistake on my part. Did I put it in the right place? dir "D:/Users/Python" – Script Kitty May 23 '15 at 02:58
  • I think you have to run the installer package by double-clicking it after you download it. Just putting it in the Python folder won't do anything I'm afraid. –  May 23 '15 at 02:59
  • Not ignoring you or abarnert, just taking forever to deal with running it with pip install. It's having a cry about my OS being 32 bit but it's really 64 so in trying to install the wheels when they're giving me this error http://stackoverflow.com/questions/28107123/cannot-install-numpy-from-wheel-format – Script Kitty May 23 '15 at 03:18
  • 1
    It has worked `PS D:\users\python> pip install mysql-python Requirement already satisfied (use --upgrade to upgrade): mysql-python in d:\users\` but for some reason or another `python manage.py syncdb` throws a different error about DLL %1 is not a valid Win32 app. Sounds like a question for another day. Thanks! – Script Kitty May 23 '15 at 03:41
0

I had the same error working on Windows, I solved it by downloading apart and then copying theMySQL_python-1.2.5-py2.7.egg-info and the MySQLdb folders and the _mysql.pyd and _mysql_exceptions.py files in C:\Users\%The-path-of-your-project%\Lib\site-packages