Python Index Page 1

python3 create new empty file

With python3 the best way to touch a file is by using the Path class from pathlib. Once you have an instance of Path (from pathlib import Path) you can use the touch method(): Path('empty_file').touch()

Python Index Page 1

How to use python to access google Spreadsheets

In this tutorial, we are going to use gspread python library to access Google Spreadsheets. We are going to see how to set up credentials on your google account and then how to use the python library to access the spreadsheet. As an example, we will provide a script the calculates the total portfolio value and saves it on the spreadsheet to have a historical data

Python Index Page 1

How to install a dependency with pip from github using setup.py

Steps to install a python dependency from git in the setup.py using dependency_links. Make sure the user is using this format: git+https://github.com/user/repo.git#egg=project_name . Check here for more details.

Python Index Page 1

Python function to generate secure random password

In this short tutorial, we will explain how to write a function to generate a secure random password generator. the function will accept size and chars as parameters. We use SystemRandom since it's more secure and provides more entropy.

Python Index Page 1

Python Pip: No matching distribution found for Twisted/Pillow

When you try to install Twisted you could get the error: "No matching distribution found for Twisted". One couse could be that you python is missing some extension, like bz2. You will need to change your pytohn interpreter or recompile it.

Python Index Page 1

Python cryptography: ImportError: No module named setuptools_ext

When you install cryptography with the command `pip install cryptography --upgrade`, the following error is raised: ImportError: No module named setuptools_ext. Try to upgrade cffi with: pip install -U cffi. Check here for all steps to solve this issue.

Python Index Page 1

Python scrapy: libxml/xmlversion.h: No such file or directory

If you have the error Python cryptography: error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 while installing python cryptography, try the following SOLUTION: sudo apt-get install python3 python-dev python3-dev build-essential libssl-dev libffi-dev libxml2-dev libxslt1-dev zlib1g-dev python-pip. Check here for full details

Python Index Page 1

pip install error: locale.Error: unsupported locale setting

When you install a apackage with pip and you get the error: locale.Error: unsupported locale setting, try to set the locale like this: export LC_ALL=C. Check out full solution here!

Python Index Page 1

Flask: How to Test file upload

Example on how to test file upload using flask client. Check here how to do a request using the FlaskClient to simulare a file upload. You need to put a tuple in the request payload with the data types: (, ) ex. file': (StringIO('my file contents'), 'test_file.txt'). Check here for a full example

Python Index Page 1

pymssql error: src/_mssql.c:568:22: fatal error: sqlfront.h: No such file or directory

When you install pymssql and you get the error: src/_mssql.c:568:22: fatal error: sqlfront.h: No such file or directory. try to install freetds-dev with apt (sudo apt install freetds-dev)