Python Tutorial

How To Set Python Module Search Path To Find Modules

When you want to import a python module library in your python source code, you need first to make the python module library importable by adding the module package path in the PYTHONPATH system environment variable. You can also add the python module package path to the python module search path at runtime in python […]

How To Set Python Module Search Path To Find Modules Read More »

How To Import A Python Module From A Python File Full Path

When creating Python source code, you often save custom modules in separate Python files. Each of these files serves as a Python module. Occasionally, you may find the need to import these modules (whose full file paths you’re aware of) into other Python source code during runtime. This article outlines how to accomplish this.

How To Import A Python Module From A Python File Full Path Read More »

How To Connect To PostgreSQL Database And Execute SQL Statement Use Psycopg2 In Python

Psycopg is a popular python postgresql database driver library which provide access to postgresql database server. Use psycopg, you can connect to postgresql database and execute sql statement easily in python source code. This article will tell you how to connect to postgresql database server use psycopg2, it also tell you how to run sql

How To Connect To PostgreSQL Database And Execute SQL Statement Use Psycopg2 In Python Read More »

How To Resolve PSQL: Fatal: Peer Authentication Failed For User “postgres” Error When Login PostgreSQL In Command Line

When I connect to my local PostgreSQL database server with command $ psql postgres ‘postgres’ I encounter the error message psql: FATAL: Peer authentication failed for user “postgres”. :~$ psql postgres ‘postgres’ psql: FATAL: Peer authentication failed for user “postgres” After investigating I finally find the solution to fix this error. This error is because

How To Resolve PSQL: Fatal: Peer Authentication Failed For User “postgres” Error When Login PostgreSQL In Command Line Read More »

How To Fix IndentationError: Unindent Does Not Match Any Outer Indentation Level Error In Python

When I run my python script code, I meet an error like this IndentationError: unindent does not match any outer indentation level. This error is so strange and hard to find the reason. After some investigation, I finally find the solution.

How To Fix IndentationError: Unindent Does Not Match Any Outer Indentation Level Error In Python Read More »

How To Enable Or Disable CSRF Validation In Django Web Application

Django has provided a feature that can help you to avoid csrf attacks on your Django application. But sometimes especially in your development environment, you do not want this feature when sending post requests to your web server use curl in the command line, if this feature is enabled, you will get errors. This article

How To Enable Or Disable CSRF Validation In Django Web Application Read More »

How To Fix Django: TemplateSyntaxError: Could Not Parse The Remainder Error In Template File

When I develop my Django app example, I meet an error with TemplateSyntaxError: Could Not Parse The Remainder error message like below. This error is so strange but so simple to fix, but it cost me a lot of time. So I want to write down the solution here for the reader to fix it

How To Fix Django: TemplateSyntaxError: Could Not Parse The Remainder Error In Template File Read More »