Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django - Mac development, environment hell

I was trying to setup Django dev environment on Mac and arrived into a hell. It all started when trying to install PIL, which failed after trying 15 or so different recipes I found on blogs. So I wanted to install the Python, this time 2.7, and reinstall setuptools, easy_install, pip from scratch.

After just installing Python 2.7, and easy_install with setuptools for 2.7, this all in turn created such a mess that is unbelievable. Different version of Python are installed everywhere, easy_install is installed everywhere and points randomly to different python hashbangs (sometimes to #!/usr/bin, #!/usr/local/, #!/Library/...)

Now I can't even do easy_install pip, which I always could. So I'm already in a hell and I haven't even attempted to install MySQL yet.

My question finally is did anyone bump into such problems, it would help enough to know that I'm not alone.

Second, would it be easier to set up the entire environment on Ubuntu than it is on a Mac?

Thirdly, is there any guide that can really clearly explain how to set up but also tear down the stack for Python development on a Mac?

like image 481
Ska Avatar asked May 30 '26 00:05

Ska


2 Answers

It wouldn't hurt to run a VM with vagrant. This post should tell you more: http://stevelosh.com/blog/2011/06/django-advice/

Of course using virtualenv should also help alleviate some of these issues.

like image 190
Mantas Vidutis Avatar answered May 31 '26 13:05

Mantas Vidutis


I've gone through the same hell 2 weeks ago :)

I needed to make working python 2.7 and virtualenv on OSX 10.6.8. You haven't mentioned virtualenv in your question but I strongly recommend it. That way you minimize amount of globally installed packages. Everything is... cleaner. My idea is to only have following things globally:

  • python (from brew)
  • pip (via easy_install)
  • virtualenv (via pip)
  • virtualenvwrapper (via pip)
  • other through either virtualenv or buildout

I've just checked and pip PIL installs fine within my virtualenv.

Here are notes from this battle (gist.github.com):

#NOTE: .pydistutils.cfg seems to be not compatible with brew install python
#areas I needed to clean before installation
#clean up ~/Library/Python
#clean up .local
brew install python
easy_install pip
pip install virtualenv
pip install virtualenvwrapper
mkdir $HOME/.virtualenvs

Example .bash_profile:

#homebrew
export PATH=/usr/local/bin:/usr/local/sbin:${PATH}

# homebrew python 2.7
export PATH="/usr/local/share/python:${PATH}"

#virtualenv wrapper
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/share/python/virtualenvwrapper.sh

Good luck!

like image 27
Munhitsu Avatar answered May 31 '26 13:05

Munhitsu