Python Tutorial: How to Set the Path and Switch Between Different Versions/Executables (Mac & Linux)

In this Python Programming Tutorial, we will be learning how to set the PATH environment variable on the Mac & Linux Operating Systems.

Be one of the first 200 people to sign up with this link and get 20% off your premium subscription.

We will also learn how to modify the PATH in order to switch between different Python versions and executables. This is an essential skill that trips up many people when they first start learning Python and will definitely help you…


  1. Hey Corey, thanks for your helpful videos. Truly a gamechanger.
    I have one question though, why do you always restart your terminal instead of just using "source .bash_profile" after updating your "bash_profile"?
    All the best.

  2. Hey Corey, error message help.

    Traceback (most recent call last):
    File "/Users/ricklien/Desktop/Github/Samples/", line 4, in <module>
    request = urllib3.request.Request(url)
    AttributeError: module 'urllib3.request' has no attribute 'Request'
    [Finished in 0.1s with exit code 1]
    [cmd: ['/anaconda3/bin/python', '-u', '/Users/ricklien/Desktop/Github/Samples/']]
    [dir: /Users/ricklien/Desktop/Github/Samples]
    [path: /anaconda3/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin]

  3. Hey, Corey, his is really helpful! Thanks very much for making this video. I have a question about the path variable in Jenkins! In Jenkins, if you execute shell and type python command to run the script, it launches python 2.7 by default even though I set the python3 as default in terminal command. So I have to type python3 in the shell to launch python3. Do you know anyway to set python3 as default version in Jenkins? Thanks very much!!

  4. Your explanation of the export command in the .bash_profile is not correct….
    If you set an environment variable that variable is only known in that shell. The export command makes sure that the environment variable you set in your current shell is passed to new shell/commands you start.
    you don't need a seperate export command you can
    export VAR=value
    in one line.

  5. I'm using z-shell and oh-my-zsh. When I run echo $PATH, I see at least a few more colon-separated references than are defined in .zprofile, .zshrc or even bash_profile… Any ideas where they might be coming from?

Leave a Reply

Your email address will not be published.