Cochinita Journal

Learn Python or Linux First? A Practical Order for Beginners

If your goal is to start programming, learn Python first and learn the shell commands you need as your projects require them. You do not need to master Linux before writing Python on Windows. If your target role is DevOps, cloud operations, security, or Linux server administration, learn Linux in parallel because the operating system is part of the job.

Python does support Windows

The Python documentation for using Python on Windows explains Windows-specific Python behavior and how to obtain and run Python on Microsoft Windows. Microsoft also has a Microsoft Python on Windows guide that starts from PowerShell, installs Python, and verifies it with python --version. So the reason people recommend Linux is not that Python cannot run on Windows; it is that many servers, deployment tools, and tutorials use a Unix-like environment.

Choose the order by your target

  • General beginner, automation, data analysis, or web basics: start with Python syntax, files, packages, debugging, and small scripts on the system you already use.
  • Backend developer: start Python now, then add Linux commands, SSH, environment variables, logs, services, and deployment workflow before you deploy.
  • DevOps, SRE, security, cloud, or server administration: learn Python and Linux together from the beginning.
  • Windows desktop automation: Python on Windows plus basic PowerShell may be more useful at first than Bash.

Create the virtual environment with the right command for the system

The Python virtual environment tutorial explains that a virtual environment isolates packages for one project. On Windows, after installing from python.org or the Windows Python tools, you may use py or python depending on your install. Choose one command that works; these are alternatives, not two required steps:

py -m venv .venv
python -m venv .venv

On Linux, macOS, or WSL, the command is often python3:

python3 -m venv .venv

Activation is convenient but not required. You can activate the environment, or you can call its interpreter directly:

# Windows PowerShell
.\.venv\Scripts\Activate.ps1
.\.venv\Scripts\python -m pip install requests

# Linux, macOS, or WSL
source .venv/bin/activate
.venv/bin/python -m pip install requests

If PowerShell blocks activation because of execution policy, do not paste broad global policy changes from random tutorials. Either call .\.venv\Scripts\python directly, use an organization-approved policy, or make a temporary current-process change only if you understand your environment's rules.

Do not copy a Windows venv into Linux

A virtual environment contains platform-specific paths and executables. A Windows .venv should not be moved into Linux or WSL and expected to work. Commit your source code and dependency list, then rebuild the environment on the target system:

# Windows: export from this project environment
.\.venv\Scripts\python -m pip freeze > requirements.txt
# On the other system:
python3 -m venv .venv
.venv/bin/python -m pip install -r requirements.txt

Export from the project environment, not the global Python installation. Some dependencies are Windows-only or require different system libraries on Linux; review those requirements before installing on the target. Recreating the environment does not guarantee that every dependency or OS-specific Python call is portable.

PowerShell and Bash are different shells

Python code can be portable, but shell commands are not automatically portable. PowerShell uses commands such as Get-ChildItem and has its own quoting rules. Bash uses commands such as ls, grep, chmod, and shell expansion. File paths also differ: Windows commonly uses C:\Users\Name\project, while Linux uses /home/name/project.

To reduce friction, use Python libraries such as pathlib for file paths, run packages through python -m pip, and learn the shell that matches where the project actually runs.

A small project that teaches both Python and necessary shell

Build a command-line expense summarizer. Put a CSV file such as expenses.csv in a project folder, write summarize.py to total spending by category, and run it from the terminal.

  1. Create a folder and move into it: mkdir expense-tool, then cd expense-tool.
  2. Create a virtual environment with the command for your system.
  3. Write Python that opens the CSV, parses rows, handles missing data, and prints totals.
  4. Run it with the venv interpreter: .\.venv\Scripts\python summarize.py on Windows, or .venv/bin/python summarize.py on Linux/WSL.
  5. Use a few shell commands only when they serve the project: list files, create folders, inspect output, and run the script again.

The Microsoft WSL overview is useful when you want a Linux environment on a Windows computer. Use WSL when the project will later run on Linux servers, when you need Bash tools, or when the tutorial you follow assumes a Linux package manager. For pure Python basics, Windows is enough.

Back to Journal