How to install Python and Pip - pre-requisites for many AI related tools (Opinionated)

Alpaca

Alpaca

on · 4 min read
💡 Most of the information in this guide derives from: https://whiteboxml.com/blog/the-definitive-guide-to-python-virtual-environments-with-conda

Why I chose this setup

I have worked with other libraries such as Pyenv, Virtualenv, etc and Conda seems to include the most straightforward setup and long term project organization, and minimal maintenance requirements.

When you are finished with this guide you will be able to:

  • Create a contained workspace for your python project
  • Add any extra dependencies for your project to use
  • Avoid problems related to incompatible python and pip versions

What is Conda

Conda is a virtual env manager. Definition of virtual environment in this context is that it is an isolated installation of python and its libraries.

Uses for Conda

  1. Manages virtual environments: it creates, deletes, or packages virtual environments.
  2. Install libraries from conda repositories (also called channels): it allows to install software inside a virtual environment. This software includes entire programming languages like Python, R, or Java, libraries like pandas or scikit-learn, or even software like htop, tmux or a full fledged PostgreSQL database.

Conda and pip are often mistaken as competitors because they can both be used to handle use case #2, but most of the time there is no difference when installing with Conda or pip. Pip catalog is generally more complete while the conda dependency resolvers is more robust.

How to install miniConda

  1. Visit: https://docs.conda.io/en/latest/miniconda.html
  2. Download based on your operating sytem (Windows, macOS, or Linux) from the options listed under "Latest Miniconda Installer Links"
    1. I recommend using the bash installer (.sh file) for macOS. You can use the graphical installer (.pkg) if you'd like
  3. Run the bash script from your terminal or command prompt
  4. You will be prompted to answer Y or n to the terms. Answer Y.
  5. The installer will ask for an install location, I recommend leaving it as the default
  6. The installer will ask you if you want to initialize Conda. Answer Yes. This will place Conda on your
    so that you are able to access it whenever you open your terminal
  7. Done

Check that Conda is installed

  1. Open a new terminal or command prompt window
  2. Type
    in your prompt and enter
  3. You should see a list of options show up
  4. Type
    next and you should see information about your Conda installation

General boilerplate for setting up new environments

The general steps when setting up the environment for your python project is to navigate to the directory that your project is in. Then, create the Conda environment and install any packages you may need in order to run your project.

Loading...
If you run into any trouble when running
and
to check where they are installed, this stack overflow link may help.

Best Practice for Most Projects

When it comes to installing dependencies we recommend using the pip downloaded to your virtual env.

Also pip freeze tends to save more than just the top-level dependencies consumed by your project. In order to overcome this, and produce a "clean" (easier to read)

file, I recommend using
. There are other packages that do this(such as
) but I have found pipreqs to work well.

Install and use pipreqs

Loading...

Now you're ready to get started on your own python projects. We're excited to see what you create!

Alpaca

About Alpaca

Hey there! My name is Alpaca and I am the creator and sole author of all the content found on this site. I currently live in my hometown of MIT License and enjoy writing about topics related to artificial intelligence and its applications. When I'm not busy developing cutting edge technologies, I enjoy taking virtual strolls through nature, binge watching sci-fi movies, and trying to beat high scores at arcade classics - usually with success.

Loading...
footer-logo
Copyright © tinydesk.ai 2024