Sunday, January 12, 2014

Error on upgrading setuptools using pip

Today I upgraded pip using below command as for some reason some of the package it was not able to find and throwing strange error that its not able to find the requested package -

pip install --upgrade pip

Existing installation was 1.0.2 and it installed the 1.5

After the upgrade, it started throwing following error on requesting any install

Wheel installs require setuptools >= 0.8 for dist-info support.
pip's wheel support requires setuptools >= 0.8 for dist-info support.
Storing debug log for failure in /Users/Jaimin/.pip/pip.log

What it means is my pip install 1.0.2 had old setup tools and after upgrading to 1.5 it needs newer version of setup tools.

Js-MacBook-Pro:dj16 J$ pip install --upgrade setuptools
Wheel installs require setuptools >= 0.8 for dist-info support.
pip's wheel support requires setuptools >= 0.8 for dist-info support.
Storing debug log for failure in /Users/Jaimin/.pip/pip.log

So it still throws the error on upgrade of setuptools, you need to use following command to upgrade -

pip install setuptools --no-use-wheel --upgrade

It will be able to upgrade the setuptools and pip should work fine after this.

Thursday, January 9, 2014

Django 1.6 global name 'timezone' is not defined

If you are following the documentation to run the sample app, while doing date time comparison you might run into the issue on following code -

 def was_published_recently(self):
        return self.pub_date >= timezone.now() - datetime.timedelta(days=1)
    was_published_recently.admin_order_field = 'pub_date'
    was_published_recently.boolean = True
    was_published_recently.short_description = 'Published recently?'

It complains - global name 'timezone' is not defined

because it needs explicit import -

import datetime
from django.utils import timezone

Once you add it should be resolved.