Skip to main content

Build Status License: MIT PyPI Downloads

PythonAnywhere cli tool

pa is a single command to manage PythonAnywhere services.

It is designed to be run from PythonAnywhere consoles, but many subcommands can be executed directly from your own machine (see usage below).

Installing

On PythonAnywhere

In a PythonAnywhere Bash console, run:

pip3.10 install --user pythonanywhere

If there is no python3.10 on your PythonAnywhere account, you should upgrade your account to the newest system image. See here how to do that. pa works with python 3.8, 3.9, and 3.10 but we recommend using the latest system image.

On your own machine

Install the pythonanywhere package from PyPI. We recommend using pipx if you want to use it only as a cli tool, or a virtual environment if you want to use a programmatic interface in your own code.

Usage

There are two ways to use the package. You can just run the scripts or use the underlying api wrappers directly in your scripts.

Command line interface

pa [OPTIONS] COMMAND [ARGS]...

Options:
  --install-completion  Install completion for the current shell.
  --show-completion     Show completion for the current shell, to copy it or
                        customize the installation.
  -h, --help            Show this message and exit.

Commands:
  django    Makes Django Girls tutorial projects deployment easy
  path      Perform some operations on files
  schedule  Manage scheduled tasks
  students  Perform some operations on students
  webapp    Everything for web apps: use this if you're not using our experimental features 
  website   EXPERIMENTAL: create and manage ASGI websites

Django autoconfigure and slow startup

pa django autoconfigure completes the Django configuration and opens a Bash shell with the project's virtualenv activated. If the reload API reports slow_startup_error, the command prints a warning to stderr and still opens that shell. Website startup remains unconfirmed; check the website's server and error logs. The command does not retry the reload.

Other API and network errors still abort autoconfigure. This warning handling currently applies only to pa django autoconfigure, not pa django start or the legacy scripts.

Running pa on your local machine

pa expects the presence of some environment variables that are provided when you run your code in a PythonAnywere console. You need to provide them if you run pa on your local machine.

API_TOKEN -- you need to set this to allow pa to connect to the PythonAnywere API. To get an API token, log into PythonAnywhere and go to the "Account" page using the link at the top right. Click on the "API token" tab, and click the "Create a new API token" button to get your token.

PYTHONANYWHERE_SITE is used to connect to PythonAnywhere API and defaults to www.pythonanywhere.com, but you may need to set it to eu.pythonanywhere.com if you use our EU site.

If your username on PythonAnywhere is different from the username on your local machine, you may need to set PYTHONANYWHERE_USERNAME for the environment you run pa in.

Programmatic usage in your code

Take a look at the pythonanywhere.task module and docstrings of pythonanywhere.task.Task class and its methods.

Legacy scripts

Some legacy scripts (separate for each action) are still available.

Contributing

Pull requests are welcome! You'll find tests in the tests folder...

Requires uv.

# prep your dev environment
uv sync --extra test

# running the tests:
uv run pytest

# make sure that the code that you have written is well tested:
uv run pytest --cov=pythonanywhere --cov=scripts

# to just run the fast tests:
uv run pytest -m 'not slowtest' -v

Metadata

Release files for pythonanywhere 0.19.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pythonanywhere 0.19.4
File Size Uploaded Provenance Actions
pythonanywhere-0.19.4.tar.gz 58.3 kB Without provenance Details for pythonanywhere-0.19.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pythonanywhere 0.19.4
File Interpreter ABI Platform Actions
pythonanywhere-0.19.4-py3-none-any.whl Python 3 none any Details for pythonanywhere-0.19.4-py3-none-any.whl

Total release size: 105.6 kB

Release files / pythonanywhere-0.19.4.tar.gz

Download URL pythonanywhere-0.19.4.tar.gz
Size 58.3 kB
Tags Source
SHA-256 checksum
How to use checksums
20c5592de5c6612b2a5d58118afcf7f43465b6053e1730807d348097da031496
BLAKE2b-256 checksum
How to use checksums
e8dc87bfdbe89bd094fcbdb63a9f9a5209c134f22226794acb04e1b0891bea47
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / pythonanywhere-0.19.4-py3-none-any.whl

Download URL pythonanywhere-0.19.4-py3-none-any.whl
Size 47.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
989b290d7f4f0211678de06ca917b7e0c7234f48ba390f3da73e5688e061ea8b
BLAKE2b-256 checksum
How to use checksums
45caf2079cdc2dae84c0e6854132481b4414b6b9a4877e15c96016b676f726f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Security for pythonanywhere 0.19.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.19.4 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page