2đź‘Ť
for windows 7 32 bit installation of python 2.7 ..
activate the virtual environment and then at the environment prompt type
easy_install mysql-python
using pip did not work for me
1đź‘Ť
VIrtualenv hasn’t inherited your global Python libraries, it doesn’t by default anymore.
You can recreate the virtualenv with the site packages, or you can install the mysql python module, which is built in C, and therefore less simple than most pip installs.
To install mysqldb under virtualenv, you need to be able to compile the mysql module, which means you need all the general compliation tools, the python header libraries and the mysql client ones (Under ubuntu/debian these are packages build-essential, python-dev & libmysqlclient16-dev ), at this point pip install MySQL-python should work, and from there you should be able to use mysql within django.
Doing this under windows, however, is complicated. One thing you can also do is add a file to the site-packages directory inside your virtual environment (lib/python2.7/site-packages) called something like mysql.pth (anything.pth will do) which contains a single line with the full path to the location of the mysql python libraries. This will add that directory to the searched path, and should also mean django can find the libraries.
- [Django]-Insert a variable from JS to Django form input field
- [Django]-Django: In django-tables2 how to modify the way URLField gets rendered
1đź‘Ť
Extending previous answer, to inherit from system’s site-packages with a recent version of virtualenv, use
virtualenv --system-site-packages test
- [Django]-Pass field value to custom layout.Field
- [Django]-Django official tutorial for the absolute beginner, absolutely failed!
1đź‘Ť
If you have installed mysql-python on C:/python27 or globally, then just copy paste the following files from “C:/python/lib/site-packages” to your virtual environment “/lib/site-packages”
- MySQL_python-1.2.4-py2.7.egg-info(folder)
- MySQLdb(folder)
- _mysql_exceptions.py/.pyc/.pyo
- _mysql.pyd
**Don’t need to copy mysql files from “C:\Python27\Lib\site-packages\django\db\backends” or “C:\Python27\Lib\site-packages\django\contrib\gis\db\backends”. It worked like a charm
- [Django]-What may cause a Page Not Found error in flatpages?
- [Django]-AttributeError: 'DatabaseWrapper' object has no attribute 'set_schema_to_public' (tenat_schemas)
- [Django]-Django test set created_at field
- [Django]-Django strange SlugField validation, error not raised before clean(), uncleaned data returned
0đź‘Ť
Looks like MySQLdb is not installed or at least not in the right place.
I used itsadok’s answer on Integrating MySQL with Python in Windows for my windows installation. You just download the installer and install it. I don’t know how it goes with virtualenv.
- [Django]-Amazon ELB + Django HTTPS issues
- [Django]-Custom widget not validating only the first time
- [Django]-How do I use BeautifulSoup to search for elements that occur before another element?
- [Django]-Empty ChoiceField selection in Django forms
- [Django]-How to sort by within a Django list
- [Django]-Identify which polygon contains a point with Django?
- [Django]-How do I resolve access denied aws s3 files?
- [Django]-Django-CMS plugin not appearing
- [Django]-Circular dependency in Django
- [Django]-Django: filter queryset when 2 fields have same value