Virtual Environment Explorer¶
Run the Virtual Environment Explorer MicroSim Fullscreen
You can include this MicroSim on your website using the following iframe:
<iframe src="https://dmccreary.github.io/robot-arm/sims/virtual-environment-explorer/main.html"
height="602px" width="100%" scrolling="no"></iframe>
Description¶
Predict what an import or a pip install does in eight terminal situations while the package lists of system Python and two virtual environments stay in view, then run your own commands. Used in Chapter 1.
Three boxes show the places Python can run from: system Python, the arm-lab environment and the old-project environment. The box Python is using is highlighted and tagged ACTIVE (or IN USE for system Python). The dark box is a pretend terminal. Its prompt starts with the name of the active environment.
The package versions are illustrative. In the pretend terminal, activate arm-lab is shorthand for running source .venv/bin/activate inside that project's folder.
Lesson Plan¶
Grade level: Middle school and up (age 12+). Time: 10 to 15 minutes.
- Read the three boxes. Find the box that is highlighted. That is where Python will look for libraries.
- Predict. Read the command in the terminal and press a, b or c before the output is shown. You get one attempt per scenario.
- Check the reason. The terminal shows the real output, and the reason appears under it. Mastery is 7 of 8.
- Explore. After scenario 8, choose Explore in the menu. Pick a command and press Run. Try to make a
ModuleNotFoundErrorappear, then make it disappear. Reset puts the three boxes back to the start. - Think about it. You installed matplotlib while
arm-labwas active. Why canold-projectnot import it?
Specification¶
The learning objective, evidence of mastery and content for this MicroSim are specified in Chapter 1: Setting Up Python for Robotics.
References¶
- venv: Creation of virtual environments - Python Standard Library documentation - How a virtual environment is created and activated, and what the folder contains.
- PEP 668: Marking Python base environments as externally managed - Python Enhancement Proposals - The rule behind the externally-managed-environment refusal when no environment is active.