Django on Mac OS X requires install of MySQLdb - django

I tried setting up Django to use a MySQL database and it choked because the backend was not available. Reading around the net I see that MySQLdb needs to be installed, and perhaps _mysql needs to be installed as well. I have been surprised that so many different sets of instructions are available, which all seem to do different things in the install process. There are also a large number of posts about the problems with installing MySQLdb, and frequent comments about the install being a PIA. This gives me pause, as I imagine that arbitrary choices which I may make may cause random and hard to track down bugs.
Is there a consensus on what the most reliable install method is?
I don't mind configuration issues. I'm just hoping not to create original problems. As a general rant, with MySQL being so common of a DBMS, why isn't the backend already installed in Django?

I use Homebrew to install stuff like MySQL. It's pretty simple:
Install Homebrew:
ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
Install MySQL using Homebrew:
brew install mysql
Install the MySQL Python module using your preferred Python installation mechanism (I prefer using Pip):
pip install MySQL-python
As a general rant, with MySQL being so common of a DBMS, why isn't the backend already installed in Django?
You can use other database backends with Django (SQLite or PostgreSQL, for example), and the MySQL connector itself is a module installed outside of Django (and potentially used by other software -- it many cases it might already be installed).

Related

Package a Django application as a desktop application

We are considering using Django for an application which can be seen mostly as a desktop application. That is, it is not to be installed on our servers, but directly on our customer's laptops (but still accessed through their browser on localhost.)
Whilst it is OK to require Python to be installed, it is not to require to install Django, or other dependencies.
It would probably run using the internal runserver. And most likely not use SQL (or only SQLite if necessary.)
Is it possible to "package" the application with Django and all dependencies? What are the options here? Ideally, the install guide would read:
install Python, if not done yet
download and unzip our application archive
go to that dir and execute python3 manage.py runserver
Note I: The goal is NOT to package a publicly available website as an app.
Note II: The only related questions I have found are several years old (10 and 7 years old resp.)
Note III: The customers use Linux, Mac and Windows.

Unable to download distribution package for Django

I'm currently testing with a django web application using version 1.6 with a python version 3.4.1 and needs to install some packages here on my machine. Based from what I've observed we are currently connected to a proxy server which is why I'm having issues downloading some of it. Below are the actions that I've taken so far.
1) I've updated my http_proxy connection to http://innoproxy:8083/proxy.pac which is our current proxy connection.
2) Below is error that mostly occurs when I would install the South Package.
C:\Users\fx0.MANDAUE>pip install South
Downloading/unpacking South
Cannot fetch index base URL https://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement South
Cleaning up...
No distributions at all found for South
Storing debug log for failure in C:\Users\fx0.MANDAUE\pip\pip.log
My question is, would it be possible for me to install that package without using the command prompt(manual download) or do I still lack some actions from my end for the downloading to work? I've already checked other possible solutions but so far to no avail. Thanks!
I'm in a similar situation behind my corporate proxy. You may first want to check whether your proxy is looking for authentication, in which case setting you connection string to http://username:password#proxyserver:port/ may help. In my case, however, our authentication relies on Windows Active Directory, which I've yet to overcome on my Linux box.
If all else fails, as in my case, you can manually download the source tar.bz (or similar compressed directory) from PyPI and use pip install path/to/source. This will mean manually downloading all dependencies and installing them the same way. It can be a pain, but it works.

Best practices of using virtual environment for web development with Django?

This is a Django and Python and maybe just a general web development question.
what's the difference between using virtualenv vs vagrant vs virtual box and etc... ?
I'm kinda confused as to when to use which one :/ I've been using virtual env this whole time and creating new virtual environments for different projects....
Is this the right way to do it?
One virtualenv per project?
I'm not really sure when and where vagrant comes into play...Am I supposed to set up vagrant and then use virtualenv?
This is probably a silly question but...if I were to be working on this project with other people. Would they too have to set up a virtual env? Just to collaborate?
Wouldn't it make more sense that we all work on our local machines and then push it into the main branch? I'm just kinda confused .... I feel like I'm doing it all wrong...
Thanks for the replies everybody!
Virtualenv sets up a local sandbox for you to install Python modules into.
Vagrant is an automation tool for creating Virtual Machines.
VirtualBox is a free, open source environment for running virtual machines, like those created by Vagrant.
Virtualenv is really about all you'll need to do sandboxed development on your local machine. We use Vagrant at my work to automate the creation of VMs. This way new developers coming on to a project have basically zero configuration to do in order to start working.
If you're collaborating with other devs, they don't need to do any of the above to work on your Django project, but if there's a lot of configuration involved that can't be done with pip and a requirements.txt, then you might look at Vagrant to ease some of that automation.
But you are correct in your assumption that you can all just work on a local branch and push back to the repo. Everything else is just icing.
Virtualenv is a python construct that holds a specific set of packages, separate from your system packages. The version of Python and its packages that came with your OS or that you installed separately is a "system package".
Virtualbox is totally different -- it's a VM, an entire operating system in a box.
I'm not familiar with Vagrant.
All you need is virtualenv. Create a new virtualenv for each project (they're very lightweight!) You need to do this because the whole point of virtualenv is to isolate the exact packages and versions of those packages you need for your project. Then activate the virtualenv and use pip install to install the packages you need, presumably starting with Django itself.
Once you have all the packages you need, use pip freeze > requirements.txt to create a file called requirements.txt that records all of the packages you've decided to use.
When other people collaborate on your project, they can start a virtualenv, pull your code into it, and run pip install -r requirements.txt to replicate your environment. They can even modify requirements.txt, push that back to you via your version control system, and you can run pip install -r requirements.txt yourself to modify your environment to match their changes.
This is all essential because without virtualenv, the problem of, for instance, having one project on your computer that requires Django 1.4 and one that requires Django 1.5 becomes very complicated.
Virtualenv is not an entire operating system in a box, just a python environment, so even if you are using it, you are still working on your local machine.
We use virtualenv and a Ubuntu virtual machine. Here's why:
virtualenv allows us to have isolated Python environments on a given operating system instance
Using Ubuntu dekstop in a virtual machine for our Python development mimics what it will look like when deployed on the server which is also Ubuntu. This means that we understand precisely the external OS package dependencies and configuration. You don't get this easily when you use OSX or Windows for development and Linux for deployment.
One important point is that a virtual machine is portable. You can take a snapshot and deploy it elsewhere easily. With Vagrant and Ansible combination you can automate a remote deployment.

How to Install Solr to use with Haystack in Django

I'm installing Solr to be used with Haystack / Django.
How do I go about installing Solr? Do I need to follow the online instructions exactly and install services like Tomcat?
The above questions I just commented make all the difference if you are set on installing / setting this up yourself. OR you could use a hosted service (read: easy).
Try out http://websolr.com I'm loving it.
If you are on OSX and want a local Solr instance just to try out for some development, this is an awesome tutorial: http://realityloop.com/blog/2011/07/19/setting-multicore-apache-solr-os-x-using-homebrew
essentially brew install solr, and then some configuration.
If you are trying to do a production level solr server on a linux operating system, I would suggest working with an instruction set specific to that distribution and the version you are using. OR even better, bite the bullet and pay someomne who knows what they are doing to set it up (make sure your indexes won't fail or go down).

Run Pinax without VirtualEnv

Is there a way to run Pinax without virtualenv?
I want to run it without virtualenv as I want to run it on a django-container on mediatemples grid-hosting service. Their containers can scale upto 1Gb of dedicated memory, so I wouldnt have to worry about my own VPS or scaling issues. But their response was:
" because of the way the DjangoContainer works, you won't be able to configure your server to use your virtualenv. Essentially the DjangoContainer is a virtualized server (to which you don't have access other than the AccountCenter tools, or the 'mtd' command line tool) with the specific purpose of serving your Django applications. It mounts your django container folder so that it has your application code, but you cannot modify the version or location of python it uses. This probably means you'll have to use Pinax without virtualenv support, as the general idea of using virtualenv in this way would be to create a custom environment for your Pinax application, which as I mentioned here is impossible to instruct the server to use. "
As of 0.9a1, Pinax can be used without pinax-boot.py which was the virtualenv dependency (we bundled it). Requirements are project-level and must be installed with pip. However, setup_project does enforce a virtual environment when installing requirements (it calls pip for you as a convenience; I would be open to not enforcing a virtual environment here). You can pass --no-reqs to setup_project forcing it to skip dependency installation. You can then run pip yourself and install it however you like.
technically yes, but you would have to change out quite a bit of the configuration that is handed out and hand install a lot of libraries. Pinax has virtualenv as a very low level built in assumption.
you can, all you need to do is find out what is in the virtualenv. set it up and install yolk in the virtual env and type yolk -l to see what you need to install to get it to work.