How to replace setup.py with the simple, elegant, powerful pyproject.toml for Python user programs.
How to install SpacePy in Python, which allows read/write NASA Common Data Format .cdf files in Python.
How to setup your program for pip install to share your code via PyPi.
This Python script will print the name of all changed files and run a viewer/editor on them. Handy for Jekyll change previews.
How to install OpenCV extra contributed modules for Python.
How to cross-platform compile OpenCV 3.3 for Python.
How to use apt install from python setup.py install
How to install Python 3.6, pip, numpy, etc. on CentOS with EPEL or Anaconda Python.
Find a random available local port from terminal using pure Python.
How to use setup.py python_requires to require a minimum Python version to install, avoiding confused users.
How to rename conda Python environments.
How to write multipage TIFF from Python with tifffile.
How to install/upgrade Python Spyder, a Matlab-like IDE.
How to manually download tar.bz2 files for conda install. Useful for sites with poor Internet connections.
Quick example of sending email from Gmail via SMTP from Python. Should use Oauth instead of password.
How to install OpenCV 3.3 via conda/pip, or compile OpenCV 3.3 for higher performance.
How to run Python scripts/subprocesses at low priority in Windows and Linux.
How to use command-line Python to recursively check a website for broken internal/external links.
How to elegantly read last line(s) of file or stream with Python collections.deque.
How to install Intel Distribution for Python 3.6 2018, and comparison to Anaconda Python.
Use vmin=1 to avoid ValueError with Matplotlib and LogNorm().
How to setup and demo CUDA GPU from Anaconda Python
How to dynamically update in-place Python Terminal text cross-platform.
Python 3.6 made pathlib stdlib. For subprocess, enclose Paths in str() for Windows commands.
How to work around issues where import matplotlib.pyplot fails due to DLL load failure.
How to use pathlib.Path instead of strings for filenames & pathnames in Python 2/3 compatible way.
How to reshape matrix ↔ vectors when calling Python from Matlab.
Matlab Engine for Python allows calling Matlab functions from Python.
Matplotlib can write platform-independent compressed video sequences.
How to write lossless AVI from matplotlib cross-platform.
How to make IPython Spyder Matplotlib plots in separate figures, vs. inline the tiny console window.
How to make Matplotlib x-axis and/or y-axis have integer-only labels.
How to find any type of server open port using plain pure Python, no extra packages.
How to run Matlab/Octave code from Python using oct2py.
How to change nano default tabs to spaces–great for Python.
How to fix error “Visual C++ 10.0 required unable to find vcvarsall.bat” by installing Microsoft Visual C++ compiler.
How to install latest Python 3.6 on Raspberry Pi without cross-compiling.
How to used f2py for Python importing and high-performance running of unmodified Fortran code.
How to control Basler cameras from Python using the Pylon 5 API via Cython in Linux, Mac, Windows.
Examples of instant conversion from BGR to RGB etc. in Numpy
You can install Scipy the quick way via conda, or the general way via pip.
Simple install of Miniconda Python on Intel Edison.
Yocto 3 includes pip, but for reference here’s how to add pip via opkg.
Comparing to None instead of NaN is over 50 times faster in Python.
How to install Phidgets stepper motor controller drives for Python in Linux, Mac and Windows.
How to upgrade Anaconda to default Python 3.6.
A few easy choices for setting up OpenCV for Python
Here’s how to fix Python segmentation fault on exit, it’s a file owner issue.
How to play, record, process live audio from Python using Numpy in cross-platform fashion.
How to install Numba, which accelerates unmodified Python code. Links to examples.
How to install PyGame for easy sound playback and live keyboard callbacks in Python.
Matplotlib release notes tell you about bugs fixed and features added. They are located on the Github releases page.
Mixed binary/ASCII file reading might leave you with lists of bytes strings on the split() command after readline in Python. Here’s how to get a single string.
When you try to read even the first line of a UTF8 file with a corrupted character anywhere in the file, Python throws UnicodeDecodeError. Quick find and fix.
How to cleanly handle prerequisites from Python setup.py
For clarity, consider using @ for matrix multiply instead of .dot() in Python/Numpy.
Fix the error Visual C++ 14.0 required by installing Microsoft Visual C++ Built Tools 2015 (small install) using this procedure.
Fix MKL AVX errors upon import numpy by force reinstalling Numpy.
Python distutils.spawn.find_executable gives the path to an executable on your system PATH in Python, here’s an example.
It is slightly faster to just write Boolean Numpy arrays to h5py despite writing as enum, vs. converting bool array to uint8 via numpy.packbits. Here’s a ben...
Perhaps by my own error, nidaqmx-python appears to read synchronously – do I need to use a nidaqmx.streaming_readers to make reading asynchronous?
In March 2017, National Instruments released a complete Python API via ctypes for NI-DAQmx–here’s how to set it up.
Using an h5py context manager helps avoid exceeding ulimit errors from too many open files. Example Python file I/O context manager, including with h5py.
Numpy 1.12 adds pathlib support throughout, and upgrades rot90 and flip to handle N-D arrays–big improvement.
Recent upgrades with conda (Anaconda/Miniconda) seem to have a clashing libstdc++. Just copy over your system libstdc++ to fix the issue.
VisPy uses PyOpenGL for beautiful, fast 3-D and 2-D plotting from Python and Numpy arrays. Here’s an easy way to setup VisPy–you don’t need a discrete GPU.
Glumpy uses PyOpenGL for beautiful, fast 3-D and 2-D plotting from Python and Numpy arrays. Here’s an easy way to setup Glumpy–you don’t need a discrete GPU.
Python is a high performance language for data analytics tasks common to science and engineering. Simple guide to transition from IDL to Python with examples.
How to properly use nonlinear axes with Matlab and Python imagesc() or pcolor()
In Matlab, tilde ~ means logical not. In Python, tilde ~ means unary complement, and booleans are actually a byte, so result may be unexpected.
f2py makes running Fortran from Python easy.
How to acquire RAW Bayer masked data from the color Raspberry Pi camera module using the PiCamera Python module.
How to correct a Matplotlib ImportError when using QT/PySide.
How to execute Python programs on Windows by just typing the .py script name, as on Mac/Linux.
Python packages are switching to QT5–breaking Mayavi 4.5, which needs QT4 and Python 3.5. Setup an environment for Mayavi 4.5 & QT4 to workaround.
Python 3.6 brings worthwhile additions to the table. Python 2.7 is being abandoned before 2020. Time to upgrade!
A standalone Python script that detects if running on WSL, Cygwin, Linux, Mac, BSD, Windows, etc. using Boolean properties.
How to make advanced 3-D animated plots in Python with Matplotlib or Mayavi.
If you get black figures with Matplotlib and Cairo render errors, try this fix.
Aspell is available for Linux/Mac/Windows, and via Python we recursively spell check text files
A cross-platform (Windows/Linux) visualization of sound spectrum is enabled via Python, PyAudio and VisPy using QT. Check it out!
workaround to pass sparse matrices from Matlab to Python.
How to pick better default values for Horn-Schunck in OpenCV.
SVG can be a nice alternative to EPS for LaTeX documents, and SVG plots are easy to create from matplotlib and view anywhere.
How to import legacy OpenCV 2 functions in Python
Platform-independent one-liner to find matplotlibrc config file
easy way to request a free network port from Python
Easy check of public IPv4 & IPv6 own address via Bash and Python
Increase ulimit via Python to allow temporary large number of open threads
How to fix mismatched HDF5 library and h5py version errors.
How to use double precision complex with Fortran and Python f2py.
a few examples of matplotlib best practices
Python/SciPy offers numerous options for finding peaks, like Matlab.
How to switch between Python 2 and Python 3 in Windows like Linux.
Switching from Matlab or another language, Python can do the vast majority of jobs reasonably thrown at it. Learning Python makes you very employable.
Matplotlib sometimes puts too many decimal places in axes labels–here’s how to fix this.
GPStk Python support needs some work, here is some example code to try.
How to install and used GPSTk from Python.
GLOW is a popular model used in many populations, you can easily access it from Python with my Python scripts.
How to use OpenCV 2 and OpenCV 3 compatibly from Python.
Example of flashing LEDs on Beaglebone Black using Python
How to log Python module versions
Normally we install precompiled Matplotlib. If you need to compile Matplotlib with TkAgg, here’s how.
Python script named “findtext”
AIRtools is a popular Matlab data inversion toolbox that I converted to Python.
Use Oct2py to run Matlab code from Python
Correct syntax for SFTP Put using Paramiko on Python.
PyEphem is one of many geospace modules on Python–here’s a quick example.