Getting Your Windows Machine Ready for Python Machine Learning

Python has quietly become the go-to language for data science and machine learning. But there's a catch that many newcomers discover the hard way: getting the right environment up and running on Windows isn't always straightforward. Many of the scientific libraries Python depends on have components written in other languages — Fortran, C, and C++ among them — which makes the setup process significantly more complex than simply running a one-line install command.
If you've ever sat in a data science workshop watching half the room struggle to install packages while the instructor moves on, you already know the problem. This guide walks you through a clean, reliable solution using Anaconda and its lightweight sibling, Miniconda.
Why Standard Python Isn't Enough for Data Science
Python has come with its own package manager, pip, since 2011. For most use cases, it works brilliantly. But scientific computing is a different beast. Libraries like NumPy have non-Python internals that pip historically struggled to handle cleanly — particularly on Windows, which lacks the built-in package management systems that Linux distributions provide.
Continuum Analytics addressed this gap by creating two things: Anaconda, a Python distribution purpose-built for scientific work, and Conda, a package and environment manager that handles dependencies across languages, not just Python.
Modern versions of pip have improved significantly, but Conda still provides a smoother experience for installing data science libraries. Think of Conda as a cross-platform equivalent to system-level package managers like APT on Ubuntu — it fetches pre-built binaries rather than compiling from source, which eliminates a whole class of installation headaches.
Anaconda vs. Miniconda — What's the Difference?
Anaconda ships as a complete scientific Python distribution. Install it and you immediately get hundreds of pre-bundled packages. Convenient, but also a significant download, and realistically most of those packages will never be touched.
Miniconda takes the opposite approach. It gives you the bare minimum: Python itself, Conda, and a handful of dependencies. From there, you install only what your project needs. This guide uses Miniconda — it keeps things lean and forces you to understand what you're actually adding to your environment.
Installing Miniconda on Windows
Head to the official Miniconda page and grab the Python 3.x installer for your Windows architecture (almost certainly 64-bit). Run the installer and work through the prompts:
Accept the license agreement
Choose Just Me for a personal installation (no admin account required)
Select an installation path — avoid any folder names containing spaces, as several packages break when they encounter spaces in file paths
Leave the advanced options at their defaults: don't add Conda to your system PATH, and let it register as the default Python
Once installed, don't use the standard Windows Command Prompt to run Conda commands. Instead, open the Anaconda Prompt from the Start menu — it's a dedicated terminal that knows where to find everything.
Verify the installation with:
conda --versionAnd for more detail:
conda infoWorking with Conda Environments
This is where Conda really earns its place. A virtual environment is an isolated Python installation that keeps one project's dependencies completely separate from another's. If Project A needs NumPy 1.20 and Project B was built against NumPy 1.15, environments let both coexist on the same machine without conflict.
Python's built-in tool for this is virtualenv, which works well for pure Python projects. Conda's environment manager goes further — it can also manage non-Python dependencies and, crucially, can run entirely different Python versions within different environments.
Viewing Your Environments
conda env listA fresh Miniconda installation shows only base — the root environment created during setup.
Creating a New Environment
conda create --name myprojectBy default, the new environment inherits the Python version from base. To specify a different version — say, Python 3.9 — use:
conda create --name myproject python=3.9Need a Python 2 environment for legacy code? That's equally simple:
conda create --name legacyproject python=2.7Activating and Deactivating
Switch into an environment with:
conda activate myprojectYour prompt will change to show the active environment name. Return to base with:
deactivateRemoving an Environment
You can't delete an environment while it's active, so deactivate first, then:
conda remove --name myproject --allManaging Packages with Conda
With an environment active, you install packages using conda install. Conda automatically resolves and installs any required dependencies — sometimes a surprisingly long chain of them.
Searching for Packages
conda search kerasThis returns exact name matches. For a broader search, use wildcards:
conda search *keras*Installing Packages
Install the latest version of a package:
conda install kerasInstall a specific version:
conda install python=3.6Install several packages in a single command (recommended — Conda resolves dependencies more reliably when it sees the full picture at once):
conda install numpy scipy matplotlibBefore committing to an install, you can preview all the changes Conda plans to make without actually making them:
conda install keras --dry-runUpdating and Removing
Update a single package:
conda update numpyBring every package in the current environment up to date:
conda update --allRemove a package (and anything that depends on it):
conda remove numpyUsing Additional Channels
Conda installs packages from channels — online repositories of pre-built packages. The default channels cover a wide range, but some packages live elsewhere. PyTorch, for example, isn't in the default channels.
To search across all channels, visit anaconda.org. Once you've identified the right channel, you can either specify it at install time:
conda install -c pytorch pytorchOr add it permanently (at low priority, so defaults still take precedence):
conda config --append channels pytorchCheck your current channel configuration with:
conda config --get channelsUsing pip Alongside Conda
Not everything is available through Conda channels. Pure Python packages that live only on PyPI can still be installed inside a Conda environment using pip — just make sure you're using the pip that belongs to that environment, not a system-level one.
First, install pip via Conda into your active environment:
conda install pipThen use it as usual:
pip install unipathWhen you run conda list afterward, pip-installed packages appear with <pip> in the Channel column, making it easy to see how each package was installed.
You can also install directly from version control repositories:
pip install -e git+https://github.com/SomeUser/SomeRepo@<commit_hash>#egg=packagenameThis requires Git, which you can install through Conda:
conda install gitA Practical Example: Teaching a Neural Network XOR Logic
With the tooling in place, here's a practical demonstration: training a small neural network to replicate the behavior of an XOR gate.
XOR is a binary logic operation where the output is 1 when exactly one input is 1, and 0 when both inputs match. It maps neatly to a two-class classification problem:
Input A | Input B | Output |
|---|---|---|
0 | 0 | 0 |
0 | 1 | 1 |
1 | 0 | 1 |
1 | 1 | 0 |
It's a classic first neural network exercise — simple enough to be tractable, but complex enough to require a nonlinear model (a straight line can't separate the XOR classes, which is what makes it interesting).
Setting Up the Environment
conda create --name nnxor
conda activate nnxor
conda install kerasThe Training Script
python
import numpy as np
np.random.seed(444)
from keras.models import Sequential
from keras.layers.core import Dense, Activation
from keras.optimizers import SGD
# XOR inputs and outputs
X = np.array([[0, 0],
[0, 1],
[1, 0],
[1, 1]])
y = np.array([[0], [1], [1], [0]])
# Define a two-layer network
model = Sequential()
model.add(Dense(2, input_dim=2))
model.add(Activation('sigmoid'))
model.add(Dense(1))
model.add(Activation('sigmoid'))
# Train using stochastic gradient descent
sgd = SGD(lr=0.1)
model.compile(loss='mean_squared_error', optimizer=sgd)
model.fit(X, y, batch_size=1, epochs=5000)
print(model.predict(X))The network has two hidden neurons and one output neuron. Training runs through all four examples 5,000 times, adjusting connection weights after each example using stochastic gradient descent to minimize the mean squared error.
After training completes, the predicted outputs look roughly like:
[[0.059]
[0.947]
[0.932]
[0.052]]Rounding to the nearest integer gives 0, 1, 1, 0 — exactly the XOR truth table. The network has successfully learned the operation.
Wrapping Up
Windows has historically been a friction point for Python data science work, but Conda removes most of that friction. The workflow breaks down cleanly:
Miniconda gives you a minimal, manageable Python foundation
Conda environments keep projects isolated and reproducible
Conda install handles cross-language dependencies transparently
pip fills in anything Conda can't reach
Channels extend the available package library when needed
Once this foundation is in place, the path to libraries like NumPy, Pandas, Matplotlib, TensorFlow, and Keras is just a conda install away.
Share this article
Loading comments...