How to Install/Use Python
Unfortunately, Python is notorious for lacking a simple, out-of-the-box solution for installing and managing your packages and environments (relevant xkcd). I hope this explanation can help you understand why the best practices are what they are, get you up and running within a few minutes, and ultimately save you some time and frustration.(1) Let's get started!
- When I was first learning Python in high school, I messed up my Python installation so badly I had to completely reinstall my operating system. This is the guide I wish I had back then.
If you're not ready to take the plunge (e.g. you want to experiment first, or you only need to run a few short code snippets), I'd highly encourage online tools like Google Colab which run completely in your browser and don't require any installation (see our "Online Demo" page for more info).
If you're using Windows, I'd HIGHLY recommend using your built-in WSL (Windows Subsystem for Linux). It takes a few minutes to set up and will make every programming-related task exponentially easier, plus you can easily wipe/restore your environment without affecting your Windows installation at all in case anything ever goes wrong.
[1] Concepts/Motivation
The core Python language is occasionally updated to improve performance/security/features/bugs, and old versions are slowly deprecated according to a predetermined schedule. As such, it's highly recommended to use a recent version of Python which is still being monitored for security vulnerabilities. For an overview of which versions are currently supported, look here or here — for reference, RedPlanet currently supports Python 3.10 to 3.12.
Python packages are external code libraries which extend the language's functionality (some ubiquitous examples are numpy
for numerical computing, pandas
for tabular data, matplotlib
for plotting, and many more). The official "index" where Python packages are published/hosted/tracked/distributed is PyPI (Python Package Index) which is sufficient for most purposes. The official tool for installing packages on your computer is pip
which is included with Python(1)— but don't go installing anything yet!
pip
is a recursive acronym for "pip installs packages" — see the original 2008 blog post here.
If you simply download Python from the official website and install packages with pip
, there's a good chance you'd eventually run into some frustrating and unfixable issues. This is because by default, pip
installs packages globally on your system, which can lead to conflicts between projects and unexpected behavior when different projects require different package versions.
To avoid these pitfalls, it's best practice to isolate your project's dependencies from the global Python installation by creating separate virtual environments (in software/security, this principle is known as "sandboxing"). This ensures that dependencies remain consistent/trackable/reproducible across different systems, and your system-wide Python installation remains unaffected by project-specific changes.
[2] Tools for Python/Package Management
Over the years, several tools have been developed to simplify the process of creating and managing virtual environments. Some popular options include:
pip
/venv
— Python's built-in solution (available from Python 3.3 onwards) for creating lightweight virtual environments.virtualenv
/pipenv
—virtualenv
predatesvenv
and works with both Python 2 and 3, offering a flexible way to create isolated environments.pipenv
build on this by integrating dependency management (via aPipfile
) with environment management, streamlining workflows and reducing the need for manual configuration.- Conda — A package/environment manager with a broader scope than Python/
pip
, including support for multiple versions of Python, complex dependencies, and even programming languages other than Python. Conda has its own package index called conda-forge, but you still have access to everything on PyPI (just installpip
in a Conda environment). Conda is only strictly necessary for tasks like GPU programming. In order to actually install/use Conda, choose one of the following:- Anaconda is popular for its user-friendly GUI and pre-installed packages, but it's quite large (4.4GB), slow to update, cumbersome, and encourages bad practices — I'd recommend staying away.
miniconda
is a smaller, more minimalistic version of Conda which only includes the essentials — this is a good options for beginners who want to minimize fuss while adhering to good practices.mamba
is a third-party drop-in replacement forconda
which is much more fast/efficient — I recommend this if you're comfortable with the command line and want the best possible experience.
poetry
/pdm
/flit
/hatch
/rye
— Newer tools for Python developers which aim to simplify the process of managing dependencies and packaging projects.uv
— A new tool which aims to unify the best features of all the above tools into a single, easy-to-use interface.
[3] My Recommendation
I started with venv
, moved to mamba
for about four years, and finally settled on uv
by Astral since mid-2024. Although it's still under rapid development (it was first released in February 2024 as a drop-in pip
replacement, and only began supporting more advanced features with v0.3.0 in August 2024), it's gained a ton of traction in the Python community and many have completely switched over(1). It's now my go-to recommendation for beginners and experienced users alike, whether you're doing simple scripting, data analysis, package development, or anything else.
- see broader discussions/testimonials here
RedPlanet was fully developed and published with uv
, it's been a joy to work with :)
[4] Editors
TODO: Flesh this section out more. A quick but sufficient explanation is:
- "Jupyter Notebook" and "Jupyter Lab" are two decent editors which require minimal configuration.
- Personally, I'd highly recommend using Jupyter within VSCode (this link provides an amazing overview/explanation/tutorial). Bonus points for using VSCodium, which is functionally identical to VSCode but free/open-source and without the telemetry/tracking.