keepcalculator

06 Numbers and Powers

Set Up a Coding Environment: First Project Guide

Card No. 06·70414 · Updated · Standard formula, shown below

This guide walks you through setting up a coding environment for your very first project. You’ll learn how to install the necessary tools, create a project folder, and verify everything works with a simple test. By the end, you’ll have a clean, organized setup that you can use for any language or framework you choose to learn next.

What You’ll Need

  • A computer (Windows, macOS, or Linux) with internet access.
  • Administrator or user permission to install software (you may need your account password).
  • About 30–60 minutes of uninterrupted time.
  • No prior coding experience is required, but basic file navigation (creating folders, saving files) helps.

Step-by-Step

  1. Decide on a programming language. For a first project, choose a beginner-friendly language like Python (great for general use, data, and automation) or JavaScript (essential for web development). This guide uses Python as the example, but the steps are similar for others.
  2. Install a code editor. A code editor is where you’ll write your code. Download and install a free, popular editor like Visual Studio Code (VS Code) from its official website. Follow the installer’s prompts; default settings are fine.
  3. Install the language runtime. For Python, go to python.org, download the latest stable version for your OS, and run the installer. Important: On Windows, check the box that says “Add Python to PATH” before clicking Install. On macOS, the installer works out of the box. Verify the installation by opening a terminal (Command Prompt on Windows, Terminal on macOS/Linux) and typing python --version (or python3 --version on some systems). You should see a version number like “Python 3.12.4”.
  4. Create a project folder. In your terminal, navigate to where you want your project to live (e.g., cd Desktop) and run mkdir my-first-project. Then enter it with cd my-first-project. This folder will contain all your code and related files.
  5. Open the folder in your editor. Launch VS Code, then go to File > Open Folder (or Open… on macOS) and select the folder you just created. You’ll see the folder name in the sidebar.
  6. Set up a virtual environment (recommended for Python). A virtual environment keeps your project’s dependencies separate from other projects. In the VS Code terminal (Terminal > New Terminal), run python -m venv venv. Activate it with venv\Scripts\activate on Windows or source venv/bin/activate on macOS/Linux. Your terminal prompt should now show (venv).
  7. Create your first code file. In VS Code, click the “New File” icon (or press Ctrl+N), name it hello.py (or hello.js for JavaScript), and save it in your project folder. Write a simple line of code: print("Hello, world!") for Python, or console.log("Hello, world!"); for JavaScript.
  8. Run your code. In the terminal, type python hello.py (or node hello.js). You should see Hello, world! printed. If you do, congratulations—your environment is working!
  9. Install a linter or formatter (optional but helpful). In VS Code, go to the Extensions view (Ctrl+Shift+X) and search for “Python” (by Microsoft) or “ESLint” for JavaScript. Install the one that matches your language. This helps catch errors and keeps code tidy.
  10. Initialize version control (optional but recommended). Version control tracks changes to your code. In the terminal, run git init (if Git is installed; if not, download it from git-scm.com). Then create a .gitignore file to exclude the venv folder and other temporary files. This is a good habit for any project.

Common Mistakes

  • Skipping the “Add to PATH” step. On Windows, if you don’t add Python to PATH, the terminal won’t recognize python commands. If you already missed it, re-run the installer and select “Modify” to add it.
  • Forgetting to activate the virtual environment. If you see python not found or you’re installing packages globally, it’s likely because the venv isn’t active. Always check for the (venv) prompt.
  • Using the wrong command for your OS. Windows uses python and venv\Scripts\activate, while macOS/Linux often use python3 and source venv/bin/activate. Mixing these up leads to “command not found” errors.
  • Opening the wrong folder in VS Code. If you open a parent folder, your files may be in the wrong place. Double-check the folder name in the sidebar.
  • Not saving the file before running. If you edit code but don’t save (Ctrl+S), the terminal runs the old version. Always save before running.

Tips

  • Start small. Don’t try to set up a complex framework like React or Django on day one. A simple “Hello, world” is enough to verify your environment.
  • Use the integrated terminal. VS Code’s built-in terminal opens directly in your project folder, saving you from manual navigation.
  • Learn keyboard shortcuts. Ctrl+` toggles the terminal, Ctrl+S saves, and Ctrl+C interrupts a running script. These save time.
  • Keep your editor updated. Enable automatic updates for VS Code and your language runtime to avoid compatibility issues.
  • Write comments. Even in your first script, add # This prints a greeting (Python) or // This prints a greeting (JavaScript). It helps you remember what each part does.

Troubleshooting

  • “python is not recognized as an internal or external command” (Windows). This means Python wasn’t added to PATH. Re-install Python and check the “Add to PATH” box. If it still fails, search “Edit environment variables” in Windows, find Path, and add the Python installation folder (e.g., C:\Users\YourName\AppData\Local\Programs\Python\Python312\) and its Scripts subfolder.
  • “python3: command not found” (macOS/Linux). On some systems, Python 3 is installed as python3. If that doesn’t work, install Python via your package manager (e.g., brew install python on macOS, sudo apt install python3 on Ubuntu).
  • The terminal says “No such file or directory” when running your script. You’re probably not in the project folder. Use pwd (or cd on Windows) to check, and cd my-first-project to change into it.
  • VS Code doesn’t show the folder in the sidebar. Go to File > Open Folder and select the correct folder. If you used “Open File” instead, you’ll only see the file, not the project tree.
  • Virtual environment activation fails. On Windows, you might see an “execution policy” error. Run Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser in PowerShell, then try activating again. On macOS/Linux, ensure you’re in the project folder and use source venv/bin/activate.
  • Code runs but shows no output. Check that your print/console.log statement is not inside a function that never gets called. For Python, ensure there are no indentation errors.

Frequently Asked Questions

Do I need to install both Python and a code editor?

Yes, they serve different purposes. Python (or any language) is the interpreter that runs your code, while the editor is where you write it. You could use a basic text editor, but a code editor like VS Code offers syntax highlighting and debugging tools.

What’s the difference between a terminal and a command prompt?

They are essentially the same: a text-based interface to run commands. On Windows it’s called Command Prompt or PowerShell; on macOS/Linux it’s Terminal. VS Code’s integrated terminal works in all of them.

Can I use a different code editor like Notepad++ or Sublime Text?

Absolutely. Any text editor works, but VS Code is recommended because it’s free, cross-platform, and has a huge extension library. If you prefer another editor, the steps are the same—just open your project folder in that editor.

Why do I need a virtual environment? Can’t I just install packages globally?

You can, but global installations can cause version conflicts between projects. A virtual environment isolates your project’s dependencies, making it easier to manage and share. It’s a best practice even for small projects.

What should I do if I want to use JavaScript instead of Python?

Install Node.js from nodejs.org, which includes npm. Create a .js file, and run it with node filename.js. The rest of the setup (editor, folder, version control) is identical.

How do I know if my environment is set up correctly?

Run the “Hello, world” script. If it prints without errors, your environment is ready. You can also run python --version and pip --version (or node --version) to confirm the tools are installed.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →