1 Steps to download Python
This guide will walk you through downloading and installing Python and a code editor on your computer.
Important: You must install Python first, then a code editor. Code editors do not include Python - they are separate programs.
1.1 Installation on World Bank Machines
If you are using a World Bank managed computer, follow these simplified steps:
1.1.1 Windows (World Bank Machines)
- Open Software Center from your Start menu
- Search for “Python” and install Python
- Search for “Visual Studio Code” and install Visual Studio Code
- Both applications should install automatically through the Software Center
1.1.2 Mac (World Bank Machines)
- Open Self Service from your Applications folder or dock
- Search for “Python” and download/install Python
- Search for “Visual Studio Code” and download/install Visual Studio Code
- Both applications should install automatically through Self Service
1.1.3 After Installation on World Bank Machines
- Python and VS Code should now be available in your Applications (Mac) or Start Menu (Windows)
- Proceed to Step 3: Verify Installation below
1.2 Installation on Personal Computers
If you are installing on your personal computer, follow these detailed steps:
1.3 Step 1: Download and Install Python
Python is the programming language itself - you need this first!
Python is the programming language, and you need to install it first before any code editor.
- Go to the official Python website: https://www.python.org/
- Click on “Downloads”
- The website should automatically detect your operating system
- Download Python 3.8 or later (recommended: latest stable version)
- Select your operating system:
- Windows: Click “Download Python 3.x” → Run the installer → Important: Check “Add Python to PATH”
- Mac: Click “Download Python 3.x” → Download the .pkg file → Run installer
- Linux: Most distributions include Python, but you may need to install pip separately
- Run the downloaded installer and follow the installation prompts
1.4 Step 2: Download and Install Visual Studio Code
VS Code is the user-friendly interface for Python - install this after Python is installed.
Visual Studio Code is a free code editor that makes working with Python much easier. VS Code requires Python to be installed first for full functionality.
- Go to the VS Code website: https://code.visualstudio.com/
- Click “Download for [Your OS]”
- The website should automatically detect your operating system
- Download the installer for your system
- Run the installer and follow the setup instructions
- After installation, install the Python extension:
- Open VS Code
- Go to Extensions (Ctrl+Shift+X or Cmd+Shift+X)
- Search for “Python” by Microsoft
- Click Install
1.5 Step 3: Verify Installation
- Open VS Code
- Open Terminal within VS Code (Terminal → New Terminal)
- Type:
python --version(orpython3 --versionon some systems) - Press Enter - you should see your Python version information
- Try running a simple command:
python -c "print(2 + 2)"
1.6 Step 4: Install Required Packages
For the nighttime lights training, you’ll need several Python packages. Copy and paste this code into the VS Code terminal:
# Install required packages for nighttime lights analysis
pip install numpy pandas matplotlib seaborn scipy geopandas rasterio shapely fiona pyproj folium earthengine-api requests h5py netcdf4 plotly bokeh ipywidgets tqdm jupyterAlternative: Install using conda (if you prefer Anaconda/Miniconda):
# Create environment
conda create -n blackmarble python=3.9
# Activate environment
conda activate blackmarble
# Install packages
conda install -c conda-forge geopandas rasterio folium earthengine-api numpy pandas matplotlib seaborn jupyter plotly1.7 Troubleshooting
1.7.1 Common Issues:
Python is not found when running commands: - Make sure you installed Python first and checked “Add Python to PATH” on Windows - Try using python3 instead of python - Restart your computer after installing Python
Package installation errors: - Try installing packages one at a time if the bulk installation fails - On Windows, you may need to install Microsoft Visual C++ Build Tools - Use pip install --user package_name if you get permission errors
Permission errors on Mac: - You may need to allow the installer in System Preferences → Security & Privacy - Consider using pip install --user for user-level installations
GDAL installation issues: - On Windows: Use conda instead of pip for geospatial packages - On macOS: Install using homebrew first: brew install gdal - On Linux: Install system packages: sudo apt-get install gdal-bin libgdal-dev
1.7.2 Getting Help:
- Python.org documentation: https://docs.python.org/3/
- GeoPandas documentation: https://geopandas.org/
- Stack Overflow Python questions: https://stackoverflow.com/questions/tagged/python
1.8 Next Steps
Once you have Python and VS Code installed, you’re ready to begin the nighttime lights training materials!