Python mechanize HTTP Error 403 request disallowed by robots.txt

When running following python script i get error “HTTP Error 403 request disallowed by robots.txt”

To fix this, find

Add below

set_handle_robots is used to disable robots.txt checking. Second line will set a User-agent, so remote won’t won’t block you as a robot. See Python […]

Read More…

error: Python.h: No such file or directory

When install dlib python module, i get error

This is because missing python3-dev package. To fix, install

If you are using python virtualenv, you will need to recreate the virtualenv after installing dev package.


Read More…

ERROR: Failed building wheel for mysqlclient

When install mysqlclient python module, i get error

Fixed by installing


Read More…

pip install mysqlclient mysql_config: not found

On Ubuntu 18.04, when i install mysqlclient python module, i get error

this is fixed by installing libmysqlclient-dev

ERROR: Failed building wheel for mysqlclient See Python […]

Read More…

Running Python Application with gunicorn and nginx

Create a service file for gunicorn

Here /home/ubuntu/myapp/wagtail2 = path to the folder where web application is. /home/ubuntu/myapp/venv/bin/gunicorn = is where gunicorn installed inside virtualenv. Change these path as required. Restart gunicorn with

use following nginx config

Restart nginx


Read More…

Installing PyCharm Community Edition on Ubuntu

pycharm python editor

PyCharm Community Edition is a free python editor from JetBrains. You can download it from Download and extact the tar.gz file. Move it to a folder like

Execute sartup script

Once pycharm started, you can go to Tools menu and create a startup script. […]

Read More…

Getting started with Django Framework

Django is a python framework for developing web applications. To install Django, run

To create a project, run

Django come with built in development server. To start Django development server, change to the project folder and run

It will start a development web server on url Creating App A django project […]

Read More…

Running Web Server with python SimpleHTTPServer

SimpleHTTPServer is a python module that allow you to run web server for static files. To start web server, run

This will start a web server on port 8000. You will be able to access server in URL

To stop server, press CTRL + C To get SimpleHTTPServer run on differnt port, run […]

Read More…

Creating and using virtualenv

To create a virtualenv, run

On Ubuntu 18, this command will create virtualenv with Python 2.7. To create virtualenv with Python 3, run

Here “venv” is my virtualenv name. To activate virtialenv, go to the folder where your virtialenv folder is present, then run

You will see name of your virtualenv on […]

Read More…


Install virtualenv on Ubuntu Creating and using virtualenv virtualenv is used to create isolated python environments. With python3, you can create virtualenv with command

Install virtualenv with setuptools

Create a folder

Create virtualenv

Activate virtualenv

To exit a virtualenv, run


Read More…