I had used pyenv to manage several Python versions. However, on macOS Big Sur, it didn’t work well. Here, I introduce a way to install Python 3.9.1 using installer which can be downloaded from official site.
Visit official site and download installer. In my case, I chose macOS 64-bit Intel Installer.
Install the Python using downloaded installer. That’s it. Now you can use python3.9 and pip3.9 on terminal.
Upgrade pip3.9 by the following command:
pip3.9 install --upgrade pip
Install pipenv by the following command:
pip3.9 install --user pipenv
Alternatively, you can use poetry. Install poetry by the following command:
In this post, I introduce a way for reading images using
opencv-python . Suppose that the Python project will be managed by Pipenv (see my previous post).
You can install
opencv-python using pip:
pipenv install opencv-python
If you try to build official software, you should specify the version of package. The version can be found on PyPI. The latest version of
22.214.171.124 at 2021/01/05.
You can specify the version like this:
pipenv install opencv-python~=126.96.36.199
You can read images by the function
cv2.imread like this:
image = cv2.imread('/path/to/imagefile')
/path/to/imagefile to the path of your image. After…
Image classifier can be easily built by using deep learning especially Convolutional Neural Network (CNN). However, you can simply implement image classifier using traditional classifiers. In this post, I introduce how to build image classifier not using Deep Learning. I will not use mathematical formula. Please try to understand the overview intuitively.
Feature extraction part refers to CNN. The important concepts are window and stride. Let us denote horizontal window as wx, verticalwindow as wy, horizontal stride as sx, and vertical stride as sy.
Suppose you have a image like this:
Next, consider a rectangle (called window) whose width…
In this post, I introduce several ways to get directories and files in Python.
Suppose that the project directory is the following structure;
and, you are
You can list directories using
os.listdir . Example usage is below:
in_dir = './data'
for dirname in os.listdir(in_dir):
By running the code, you can see the output like this:
Note that you can only list the directories. If you need the path to the directories, the code should be like this:
in_dir = './data'
for dirname in os.listdir(in_dir)…
In order to make writing codes fast, completion is quite important. In this post, I introduce the way to enable completion in Visual Studio Code (vscode) for Pipenv project.
If you create Python project by following my previous post,
.venv/ is created at the project root. You can enable completion by let vscode see this
.venv/ . To do so, Select
Code -> Preferences -> Settings , and enter
python venv path` to search bar, then set
.venv like this:
Whenever you edit Python project using vscode, open vscode by the command like this:
The setting for the completion is done. Thanks for reading.
This post is linked to my Youtube channel:https://www.youtube.com/channel/UC-SHOllZQsQFCsbL3BvP1rA
The content might be updated in the future.
In this post, I introduce how to start Python project.
Install and setup pyenv by following the instruction below,
On macOS, using homebrew is easy, but I use
git clone .
After installation and setup, install some versions of Python. In this post, I use Python 3.9.1.
pyenv install 3.9.1
pipenv is a software for package management and virtual environment.
Install pipenv by the following instruction below,
After installation, add the code below to the setting file of shell (e.g.
.zshrc) to create
.venv/ under the project root.
Let us start Python project by the…