Coder Social home page Coder Social logo

multiphase-macos-env-python's Introduction

Installing Python on MacOS

Note: Depending on where you are in the curriculum and when you started the program, you may already have installed pyenv, Python, and pipenv. If so, you are free to skip this lesson. Before continuing, however, we recommend that you verify that everything is set up correctly by completing the steps in the "Verify and Troubleshoot your MacOS Environment Setup" lesson.

Install pyenv

Before installing Python, we first need to install pyenv, a version manager for Python. We will likely only use Python version 3.8.13 in the Software Engineering curriculum, but installing pyenv will make it simple to install newer versions later on.

Enter the following command in the Terminal:

$ brew install pyenv

Open your .zshrcfile in VSCode:

$ code ~/.zshrc

Add the following to the end of the file:

if which pyenv > /dev/null; then
  eval "$(pyenv init -)";
fi

We want to load pyenv every time we open a new terminal window; this will make sure that it does!

Enter the following command to load your new settings:

$ source ~/.zshrc

Install Python

Run the following command to install Python (you'll notice pyenv makes us put in the exact version instead of being able to just say 3.8 or 3):

$ pyenv install 3.8.13

After some time this should complete without any errors. It could take a while since you are compiling Python from source code.

Once this is finished we also need to tell pyenv this is our default version of Python using this command:

$ pyenv global 3.8.13

Ensure that these changes take effect by closing your terminal and opening a new one.

Check Your Work

You can verify that you have the correct version of Python installed by typing:

$ python3 --version

This command should show 3.8.13.


Install Pipenv

Another piece of software we will use in class is Pipenv. We will learn more about what Pipenv is later; for now, go ahead and install it:

$ pip install pipenv

After you have installed pipenv, modify your .zshrc file to add an export line inside the if statement we added earlier, after the eval line:

 if which pyenv > /dev/null; then
     eval "$(pyenv init - )";
     export PIPENV_VENV_IN_PROJECT=1
 fi

Save and close your shell startup file, then enter the following command once again to finish configuring your environment:

$ source ~/.zshrc

Congratulations! If you've completed all these steps you are ready to code in Python!

multiphase-macos-env-python's People

Contributors

lizbur10 avatar professor-ben avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.