Python Installation
This page will guide you through installing Python, setting up development environments, running Python scripts, and exploring basic tools for data analysis.
Installing Python
-
Download Python
Go to Python.org and download Python 3.13.7 (latest stable version). -
Install Python
- Run the installer.
- Important: Check the box "Add Python to PATH" before clicking Install.
-
Verify Installation
Open a terminal or command prompt and type:
python --version
You should see something like:
Python 3.13.7
Development Environments (IDEs)
There are several ways to write and run Python code. Here are some recommended options:
PyCharm
- IDE developed by JetBrains.
- Great for projects, especially if you have an .edu email (can get free license).
- To run a Python project in PyCharm:
- Open PyCharm and create a new project.
- Add a new Python file (
.py) in the project. - Write your code, e.g.:
print("Hello world!") - Right-click the file → Run → see output in the console.
VS Code
- Lightweight editor, requires Python extension.
- Steps to run Python in VS Code:
- Install VS Code.
- Install Python extension from Extensions Marketplace.
- Create a
.pyfile. - Run the file in the integrated terminal.
Anaconda
- Distribution including Python, many scientific libraries, and AI/ML tools.
- Ideal for data analysis and AI projects.
- Comes with Jupyter Notebook for interactive code.
Google Colab
- Online IDE for Python.
- Great for data analysis without installing anything locally.
- Visit Google Colab and start coding.
Running Python Scripts
- Save your file with
.pyextension. - Open terminal/command prompt.
- Navigate to the folder containing your file.
- Run:
python your_file.py - You should see the output in the terminal.
Using Jupyter Notebook
Jupyter Notebook is excellent for data analysis.
- Launch via Anaconda Navigator or command line:
jupyter notebook
- Create a new Python notebook.
- You can write Python code in cells and run them individually.
- Example:
import pandas as pd
# Load Excel data
df = pd.read_excel("data.xlsx")
print(df.head())
Example: Simple Python Script
Sample code:
# hello.py
import numpy
example = numpy.zeros((3, 2))
print(example)
Installation and Running:
pip install numpy
pip3 install numpy
python hello.py
Fixing Jupyter Authentication and XSRF Issues (Short Version)
Common Symptoms:
- Browser asks for password or token repeatedly.
- Errors like
403: XSRF cookie does not match POST argumentor_xsrf argument missing from POST.
Quick Fix Summary:
-
Use the correct token URL
When Jupyter starts, copy the full link shown in the terminal (it includes?token=...). -
Clear cookies for
localhost
Remove cookies in your browser or open in Incognito mode. -
Remove stored password
Edit~/.jupyter/jupyter_server_config.jsonand delete lines like:
"IdentityProvider": {
"hashed_password": "argon2:..."
}
Save and restart Jupyter.
- Disable password/token locally (optional)
Add this to~/.jupyter/jupyter_notebook_config.py:
c.NotebookApp.token = ''
c.NotebookApp.password = ''
c.ServerApp.password = ''
c.ServerApp.token = ''
c.PasswordIdentityProvider.hashed_password = ''
c.ServerApp.disable_check_xsrf = True # local only!
- Restart Jupyter
jupyter notebook stop 8888
jupyter notebook
- If still broken
Reset config:
mv ~/.jupyter ~/.jupyter.backup
jupyter notebook --generate-config
✅ Now Jupyter should open directly at http://localhost:8888 without asking for a token or password.