Skip to main content

A beginner-friendly CLI that checks whether a directory looks like a Python project and suggests what to do next.

Project description

pyenv-doctor

pyenv-doctor is a minimal Python command-line tool for beginners.

It scans a directory, checks whether it looks like a Python project, and tells you whether the current Python interpreter is running inside a virtual environment.

What It Checks

This MVP checks for these common Python project files:

  • requirements.txt
  • pyproject.toml
  • setup.py
  • setup.cfg
  • Pipfile
  • poetry.lock
  • uv.lock
  • environment.yml
  • .python-version

If at least one of them exists, the tool prints:

Conclusion: this looks like a Python project

It also checks whether the current Python is running in a virtual environment. After the scan, it prints a short list of beginner-friendly suggestions based on the result.

Supported common cases:

  • venv
  • virtualenv
  • Conda

Why Virtual Environments Are Useful

Virtual environments help keep project dependencies isolated. This makes it easier to avoid version conflicts between different Python projects on the same machine.

Project Structure

pyenv-doctor/
|-- .gitignore
|-- .github/
|   |-- workflows/
|   |   |-- ci.yml
|   |   `-- publish.yml
|-- pyproject.toml
|-- README.md
|-- requirements.txt
|-- LICENSE
|-- main.py
`-- tests/
    `-- test_main.py

Installation

1. Make sure Python 3.11 or newer is available

python --version

2. Install from PyPI

The PyPI package name is:

python-project-doctor-cli

Install it with:

python -m pip install python-project-doctor-cli

The installed command name is still:

pyenv-doctor

3. Install locally from source

Clone the repository, enter the project directory, and install it locally:

python -m pip install .

For local development, you can also use editable install:

python -m pip install -e .

Run

Run the installed CLI command:

pyenv-doctor
pyenv-doctor .
pyenv-doctor C:\my-project
pyenv-doctor . --json

Run the tool from source:

python main.py
python main.py C:\my-project
python main.py C:\my-project --json

Windows note for virtual environment detection

If you want to verify virtual environment detection on Windows, activate the virtual environment first and then run:

python main.py

This is recommended because py -3.14 main.py may use the system interpreter instead of the currently activated virtual environment.

Run Tests

Run the test suite with:

python -m unittest discover -s tests -v

Exit Codes

  • 0: the scan completed successfully
  • non-zero: the scan failed because the path was invalid or the arguments were invalid

JSON Output

Use --json to get machine-readable output:

pyenv-doctor . --json
python main.py . --json

The JSON output includes:

  • scanned_directory
  • found_files
  • looks_like_python_project
  • virtual_environment_detected
  • error
  • suggestions

Example Output

Example 1: Python project detected, virtual environment detected

Scanned directory: C:\demo\my-project

Project file detection:
- requirements.txt: not found
- pyproject.toml: found
- setup.py: not found
- setup.cfg: not found
- Pipfile: not found
- poetry.lock: found
- uv.lock: not found
- environment.yml: not found
- .python-version: not found

Conclusion: this looks like a Python project
Reason: detected pyproject.toml, poetry.lock

Virtual environment detection:
Virtual environment: detected

Suggestions:
- Open pyproject.toml to check how this project should be installed or run.
- If this project uses Poetry, review pyproject.toml and try poetry install.

Example 2: No project markers, no virtual environment

Scanned directory: C:\demo\empty-folder

Project file detection:
- requirements.txt: not found
- pyproject.toml: not found
- setup.py: not found
- setup.cfg: not found
- Pipfile: not found
- poetry.lock: not found
- uv.lock: not found
- environment.yml: not found
- .python-version: not found

Conclusion: no clear Python project markers were found
Details: common Python project files were not found in this directory.

Virtual environment detection:
Virtual environment: not detected
Recommendation: use venv or Conda for an isolated Python environment

Suggestions:
- Verify that you are scanning the project root directory.

Example 3: Invalid path

Error: path does not exist: C:\does-not-exist

Suggestions:
- Check the path spelling and try again.

Example 4: JSON output

{
  "scanned_directory": "C:\\demo\\my-project",
  "found_files": [
    "Pipfile",
    ".python-version"
  ],
  "looks_like_python_project": true,
  "virtual_environment_detected": false,
  "error": null,
  "suggestions": [
    "Open Pipfile to review the project's dependencies and environment settings.",
    "Check .python-version to see which Python version this project expects."
  ]
}

Publishing

This repository includes a GitHub Actions workflow for trusted publishing to PyPI when a GitHub release is published.

To use it, first add this repository as a trusted publisher in your PyPI project settings. Then create a GitHub release to trigger the publish workflow.

Roadmap

  • Improve test coverage
  • Improve detection rules for different Python workflows

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_project_doctor_cli-0.1.0.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_project_doctor_cli-0.1.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file python_project_doctor_cli-0.1.0.tar.gz.

File metadata

File hashes

Hashes for python_project_doctor_cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 15e3e8f8f8fc9d6e214d398e5379eba06474ede68b266d299e334703fa7976fb
MD5 149141a34f7fc194ba7c6a686a935226
BLAKE2b-256 b4ee2e6b1723e4a78073714154c7964fa66022b8d92b7ae627ae0a5a7ed23f94

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_project_doctor_cli-0.1.0.tar.gz:

Publisher: publish.yml on x1958075990h-pixel/pyenv-doctor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file python_project_doctor_cli-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for python_project_doctor_cli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c0aa6479638febd07b955e771a17395d5897ea460e30d6a1a184a677f0900463
MD5 693addf08cf3b73c36fdce8f38342720
BLAKE2b-256 5b546872975939237846ab0e9fe73576550a0d59c7d5d21c2552bb491908e214

See more details on using hashes here.

Provenance

The following attestation bundles were made for python_project_doctor_cli-0.1.0-py3-none-any.whl:

Publisher: publish.yml on x1958075990h-pixel/pyenv-doctor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page