Setup Modern Python development

First, you need to install pyenv so you can have multiple version of python in your system. then for projects that does not need packaging, you can use pyenv-virtualenv to setup requirements.txt for project based venv. Second, you need to install pipx, so it installs some shared tools for the whole system. After setting up pipx (using certain version of python specified by pyenv), pipx reuses the python interpreter on which pipx was installed, so if you upgrade python and got the previous one removed, pipx will fail....

June 1, 2022 · 1 min · shelper

Migrating to new python version with lots of dependencies

so i am using poetry to manage my venv for a project that relies on dozens of PYPI packages. i first thought it would be relatively easy to migrate python3.7 to the latest 3.10. but i was wrong, and i spent hours to fix it. Here is what i’ve learned. first of all, you need to install pyenv for multiple version management, a caveat here is that if you use the suggested method to setup (through curl https://pyenv....

May 16, 2022 · 2 min · shelper

best practice for jupyter and ipython

A few things to setup the IPython and Jupyter for a best practise. IPython configuration Change ~/.ipython/profile_default/startup/init.ipy for their usage respectively To enable versioning of the python/jupyter environment, you need to pip install version_information and then add below, afterward for each IPython notebook file I put %version_information numpy, scipy, matplotlib, pandas to display my python environment version information %load_ext version_information To enable autoloading of modified modules in IPython, add below %load_ext version_information %load_ext autoreload %autoreload 2 I also added the lines below just because I use them everytime I open IPython import numpy as np import matplotlib....

May 24, 2018 · 2 min · Shelper

how to start python project on github

steps are: install cookiecutter: python -m pip install cookiecutter run cookiecutter to initiate a project: cookiecutter('https://github.com/audreyr/cookiecutter-pypackage.git') under the project folder on github, start a new repo python_prj run git init in the local project folder and commit run git remote add origin git@github.com:username/projectname.git using git@git requires to setup the ssh key pair, this can be found by easily google it or under FAQ of github run git push -u origin master...

June 14, 2016 · 1 min · Shelper

install pyqt on mac for matplotlib

so i was trying to use matplotlib for fast image ploting and updating, and I found a post here. the matplotlib uses different backend to render the images, and due to the differences between different backend, some functions are only available for specific backend, for instance, the fig.canvas.update() is a fast way to render new images to the axes, but is only availabe to PyQt4. so i was trying to install pyqt4 using homebrew, it failed by saying the osx version is pre-released version and is not supported, and arises 2 errors during make process....

June 13, 2016 · 2 min · Shelper