Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set your subtitle preferences in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please refer to our video player troubleshooting guide for assistance.

Commonly Used Commands

00:00 As you know by now, pyenv comes with a lot of built-in commands. In this lesson, we’ll go over the most important ones, starting with the pyenv install command. You’ve already used the install command in a previous lesson.

00:17 This command can be used to install a specific version of Python. As you have seen before, you can use pyenv install --list, maybe with grep, to list all versions that you can install with pyenv. If you want to see all compilation output while installing, you can run pyenv install with the --verbose flag.

00:46 Once you have installed a couple of versions, you can use the pyenv versions command to display all of the currently installed Python versions, including system Python.

01:00 If you only care about the version that is currently activated, you can run pyenv version, which is similar to pyenv versions but only shows you the current active Python version.

01:18 The which command is helpful for determining the full path to a system executable. Because pyenv works by using shims, this command allows you to see the full path to the executable pyenv is running. For example, if you wanted to see where pip is installed, you could run pyenv which pip.

01:43 The output displays the full system path for pip. This can be useful when you’ve installed command-line applications.

01:54 The global command is yet another command you’ve already seen in a previous lesson, which is very useful for setting the default global Python version.

02:04 You will learn how to override the global Python versions for each of your projects in a minute. So, when you want to set the global Python version to 3.9.1, then just run pyenv global 3.9.1.

02:25 The local command, on the other hand, is often used to set a project-specific Python version. So, let’s move into a project directory and set the version to CPython 3.8.7 for this project by running pyenv local 3.8.7.

02:48 This command creates a .python-version file in your current directory that contains the Python version for this project. If you have pyenv active in your environment, this file will automatically activate or deactivate this version for you.

03:09 So when you check which Python version is used, you will see it is the one you just set with the local command. Now, when you move out of the project directory and check the Python version again, you will see that the global Python version 3.9.1 is used.

03:36 The shell command is used to set a shell-specific Python version. For example, if you wanted to test out a 3.9-dev version of Python, you can just install it and next run pyenv shell 3.9-dev.

03:55 This command activates the version specified by setting the PYENV_VERSION environment variable. This command overrides any application or global settings you may have.

04:10 If you want to deactivate the version, you can use the --unset flag.

04:21 In this lesson, you learned the most important pyenv commands. You might also have noticed that the Python version can be set in a couple of ways, which we’ll explore further in the next lesson.

Become a Member to join the conversation.