django is very slow on my machine

I have a fresh install of django 1.0 and a simple page served from it takes 5 secs to load. On my colleague's computer it takes almost no time. I start the server using python manage.py...

How can I parse a time string containing milliseconds in it with python?

I am able to parse strings containing date/time with time.strptime >>> import time >>> time.strptime('30/03/09 16:31:32', '%d/%m/%y %H:%M:%S') (2009, 3, 30, 16, 31, 32, 0, 89, -1) How can I...

What tools or libraries are there for decompiling python and exploring bytecode?

Lets say I have: >>> def test(a): >>> print a Now, I want to explore see how test looks like in its compiled form. >>> test.func_code.co_code '|\x00\x00GHd\x00\x00S' I can get the...

No module named _sqlite3

I am trying to run a Django app on my VPS running Debian 5. When I run a demo app, it comes back with this error: File "/usr/local/lib/python2.5/site-packages/django/utils/importlib.py", line...

PicklingError: Can't pickle <class 'decimal.Decimal'>: it's not the same object as decimal.Decimal

This is the error I got today at <a href"http://filmaster.com%22%3Efilmaster.com: PicklingError: Can't pickle <class 'decimal.Decimal'>: it's not the same object as decimal.Decimal What does...

error: can't start new thread

I have a site that runs with follow configuration: Django + mod-wsgi + apache In one of user's request, I send another HTTP request to another service, and solve this by httplib library of...

How do I copy an entire directory of files into an existing directory using Python?

Run the following code from a directory that contains a directory named bar (containing one or more files) and a directory named baz (also containing one or more files). Make sure there is not a...

Lost connection to MySQL server during query

I have a huge table and I need to process all rows in it. I'm always getting this Lost connection message and I'm not able to reconnect and restore the cursor to the last position it was. This is...

Django TemplateDoesNotExist?

My local machine is running Python 2.5 and Nginx on Ubuntu 8.10, with Django builded from latest development trunk. For every URL I request, it throws: TemplateDoesNotExist at /appname/path...

Explaining Python's '__enter__' and '__exit__'

I saw this in someone's code. What does it mean? def __enter__(self): return self def __exit__(self, type, value, tb): self.stream.close() from __future__ import...

Mocking ImportError in Python

I'm trying this for almost two hours now, without any luck. I have a module that looks like this: try: from zope.component import queryUtility # and things like this except ImportError: #...

Python analog of Unix 'which'

In *nix systems one can use which to find out the full path to a command. For example: $ which python /usr/bin/python or whereis to show all possible locations for a given command $ whereis...

How do I fix this Django error "Exception Type: OperationalError Exception Value: no such table?"

I've finally installed all the requirements (so i think!) of a Django project, and I'm trying to get a local install running on my Mac (OSX 10.4). I'm getting the following...

I have a very long and repetitive python path, where do I look to correct this?

I know it is probably not necessary to paste the whole path, but just for the record I have done so below. Whenever I run a python command, it takes a long time to load this path I suppose. I have...

How to enumerate a range of numbers starting at 1

I am using Python 2.5, I want an enumeration like so (starting at 1 instead of 0): [(1, 2000), (2, 2001), (3, 2002), (4, 2003), (5, 2004)] I know in Python 2.6 you can do: h =...

Mac Packaging: proposal for a new method(suggestions please)

Macports is the only packaging system I have checked out on the Mac and I dont like it.(it needs all its applications installed in a particular location. Thats probably the reason why it showed...

how to install python distutils

I just got some space on a VPS server(running on ubuntu 8.04), and I'm trying to install django on it. The server has python 2.5 installed, but I guess its non standard installation. When I run...

What are the benefits of pip and virtualenv?

So everyone is telling me to use pip and virtualenv but no-one is able to explain me how it is better than my current approach. The main reason for people to use pip and virtualenv seems to be...

python: walking tar archive with gzip files

I have some .tar files (ungzipped). Each of them has some .gz files. I need to walk through .tar file and get ungzipped content of all other files. so I wrote: #!/usr/bin/python2.5 -u import...

How to take inverse of 2 raise to something in python2.5 (strict)

I have a number say 37. 37 lies between 2**5 and 2**6. I want to write a function which takes the number as argument and returns the power of its lower bounderies. def foo(x=37) { result =//Here...

Django - Media upload [Errno 13] Permission denied

I'm having some trouble getting django to play nice with image uploads. My script will create directories based on the date like so: file = models.FileField(upload_to='uploads/%m-%Y/') Now, if I...

django import error - No module named core.management

Ok, I see plenty of these errors around. I have tried everything I know to do and have yet to figure this out. I am working on a development server running python 2.5 and Django 1.3. Django 1.3...

celery .delay hangs (recent, not an auth problem)

I am running Celery 2.2.4/djCelery 2.2.4, using RabbitMQ 2.1.1 as a backend. I recently brought online two new celery servers -- I had been running 2 workers across two machines with a total of...

How to send an email with Gmail as provider using Python?

I am trying to send email (Gmail) using python, but I am getting following error. Traceback (most recent call last): File "emailSend.py", line 14, in <module> server.login(username,password) ...

hadoop /usr/bin/env: python: No such file or directory

I am trying to run a hadoop streaming server with following command from a shell script hadoop jar /usr/local/hadoop/contrib/streaming/hadoop-0.19.2-streaming.jar -input $1 -output...

Python argparse errors with '%' in help string

I have a default value that contains a '%' which I also insert in to the help doc of my argument. E.g.: default = "5% foo" animrender_group.add_argument( "--foo", default=default, ...

AttributeError: 'module' object has no attribute 'python_implementation' running pip

I installed Cygwin with Python set-up tools. When I try to run pip install awscli I get the following error: $ pip install awscli Traceback (most recent call last): File "/usr/bin/pip", line 8,...

random 'module' object has no attribute 'randit'; random.__file__ directs to right module in library frameworks; other solutions have not worked

i've looked at other threads looking at the same problems and the solutions suggested there have not worked whenever i try to execute this code i get this import random print...

python import module prefixed with an underscore

hi today i ve encounterd some python magic i dont understand and that is i have script where i am using csv module like import csv and it throws $> python generate_xml.py generate_xml.py:21:...

How to set environment variables in virtualenv

If I have python script which activates the virtualenv like this: #!/path/to/venv/bin/python How can I set variables for this script without modifying this script? I want this environment...