Sep 232017

These are my notes on using some MicroPython specific tools in relation to a ESP32-DevKitC board.

There are many tutorials and youtube videos that constantly encourage users to install tools and packages into their system-level libraries. (If you need to use sudo when you pip install foo, you are installing it as a system level library.) Please, Please, Please take the time to learn the basics of virtual environment. If you are a developer/hacker/maker – save yourself lots of frustration by using virtual environments.

A virtual environment is an isolated Python environment it contains all the necessary executables to use the packages that a Python project would need. It allows you use the desired version of a specific library and isolates that library from other virtual environments and the system and user level libraries. It allows you to easily define what packages are required to reproduce your work.

A short primer based on Python3.

To Create and setup a Python3 virtualenv

# nav to where you want to create your project then ...
$ python3 -m venv your-project-name
$ cd your-project-name
$ source bin/activate
(your-project-name) $ pip install --upgrade pip

Now just use pip and skip the sudo and kludging up your system level install.

To Deactivate a virtual environment

(your-project-name) $ deactivate

to activate an existing virtual environment

$ source bin/activate
(your-project-name) $

Mandatory link to the documentation.

Now you can list the packages you have installed for THIS project with pip:

(your-project-name) $ pip freeze

(your-project-name) $ pip list
pip (9.0.1)
pkg-resources (0.0.0)
setuptools (20.7.0)

May the Zen of Python be with you.

 Posted by at 6:52 pm

Sorry, the comment form is closed at this time.