Skip to content

Latest commit

 

History

History
91 lines (65 loc) · 4.17 KB

File metadata and controls

91 lines (65 loc) · 4.17 KB

PyCharm Setup and Configuration

Installing JetBrains PyCharm and configuring a project interpreter, virtual environment, and debugger for Python security tooling.

Overview

PyCharm is a full-featured Python IDE with deep code inspection, powerful refactoring, and integrated debugging/testing. It shines when a small script grows into a maintained tool or a multi-file framework. The Community Edition is free and sufficient for security scripting; the paid Professional edition adds web/remote-development features. The key configuration task is binding each project to its own virtual environment.

Syntax

# Install via JetBrains Toolbox (recommended) or snap
sudo snap install pycharm-community --classic

# Open a project from the terminal
pycharm-community ~/engagements/acme/tooling

Explanation

PyCharm concepts:

  • Project interpreter — every project is bound to a specific Python interpreter. Set it under Settings -> Project -> Python Interpreter. Point it at an existing venv or let PyCharm create one (Virtualenv, pipenv, or Poetry backed).
  • Run/Debug configurations — named launch profiles storing the script, arguments, environment variables, and working directory.
  • Inspections — static analysis that flags bugs, unused imports, and type issues as you type.
  • Integrated debugger — breakpoints, conditional breakpoints, evaluate-expression, and a variables watch pane.
Task Location
Set/create interpreter Settings -> Project -> Python Interpreter
Add run arguments Run -> Edit Configurations -> Parameters
Set env vars Run -> Edit Configurations -> Environment variables
Toggle inspections Settings -> Editor -> Inspections
# tool.py — PyCharm's debugger can set a conditional breakpoint
# (e.g. break only when host == "10.10.10.5") on the loop line below
hosts = ["10.10.10.4", "10.10.10.5", "10.10.10.6"]
for host in hosts:
    print(f"Probing {host}")

Output

Probing 10.10.10.4
Probing 10.10.10.5
Probing 10.10.10.6

Security Use Cases

  • Refactoring a sprawling single-file scanner into a clean package using PyCharm's rename/extract-method tools without breaking imports.
  • Using conditional breakpoints to halt an exploit loop only on the target that triggers a crash.
  • Managing environment variables (e.g. API_KEY, TARGET) in the run configuration instead of hardcoding secrets in source.

Best Practices

  • Create a fresh virtualenv per project rather than reusing PyCharm's default base interpreter.
  • Store run arguments/targets in the Run Configuration, and keep configs out of shared VCS if they contain live data.
  • Enable the built-in inspections and address warnings before shipping tooling.
  • Use File -> Invalidate Caches if IntelliSense stops resolving a freshly installed package.

Common Mistakes

  • Accepting the default global interpreter instead of a per-project venv, mixing dependencies across engagements.
  • Committing .idea/ run configurations that embed target IPs, tokens, or absolute local paths.
  • Forgetting that PyCharm's "Run" uses the project working directory, which can differ from a terminal cd, changing relative file paths.

Practical Lab

Goal: build a project with a dedicated venv and debug it in PyCharm.

  1. Create a new PyCharm project and choose "New environment using Virtualenv".
  2. Confirm the interpreter path points inside the project (.../venv/bin/python).
  3. Install a package via Settings -> Python Interpreter -> + (e.g. scapy).
  4. Add a Run Configuration with a --target parameter, set a conditional breakpoint, and step through.

References

Related

  • [[Selecting-an-IDE]]
  • [[VS-Code-Setup]]
  • [[Managing-Virtual-Environments]]
  • [[Python-Environment-Setup/Readme|Python Environment Setup]] — module index
  • [[Readme|Python for Security Professionals]] — course home