### Start Django Project Source: https://help.pythonanywhere.com/pages/ASGICommandLine Use the django-admin command to start a new Django project. ```bash django-admin startproject asyncdjango ``` -------------------------------- ### Install FastHTML Source: https://help.pythonanywhere.com/pages/ASGICommandLine Install the python-fasthtml package into your active virtual environment. ```bash pip install python-fasthtml ``` -------------------------------- ### Install FastAPI and Uvicorn Source: https://help.pythonanywhere.com/pages/ASGICommandLine Install FastAPI and Uvicorn with standard extras into your virtual environment. ```bash pip install "uvicorn[standard]" fastapi ``` -------------------------------- ### Install mysqlclient Source: https://help.pythonanywhere.com/pages/AccessingMySQLFromOutsidePythonAnywhere Install the mysqlclient library on your local machine using pip to interact with MySQL databases. ```bash pip install mysqlclient ``` -------------------------------- ### Install Django and Uvicorn Source: https://help.pythonanywhere.com/pages/ASGICommandLine Install Django and Uvicorn with standard extras into your virtual environment. ```bash pip install "uvicorn[standard]" django ``` -------------------------------- ### Install Mezzanine Source: https://help.pythonanywhere.com/pages/HowtouseMezzanineonPythonAnywhere Install the Mezzanine package and its dependencies within the active virtual environment. ```bash pip install mezzanine ``` -------------------------------- ### Example Command for Always-On Task Source: https://help.pythonanywhere.com/pages/AlwaysOnTasks This is an example of the command you would enter to set up an Always-On task. Ensure you replace the path with your actual script location. ```bash python3.10 /home/yourusername/a-directory/a-script.py ``` -------------------------------- ### Check Mezzanine Installation Source: https://help.pythonanywhere.com/pages/HowtouseMezzanineonPythonAnywhere Verify that Mezzanine has been installed correctly by checking the list of installed packages. ```bash pip freeze | grep -i mezzanine ``` -------------------------------- ### Install Project Dependencies Source: https://help.pythonanywhere.com/pages/Flask Install additional project dependencies like Flask-SQLAlchemy or from a requirements file after activating your virtual environment. ```bash pip install flask-sqlalchemy ``` ```bash pip install -r requirements.txt ``` -------------------------------- ### Initial Haskell Setup Source: https://help.pythonanywhere.com/pages/Haskell Demonstrates how to compile and run a Haskell file using `runhaskell`. ```bash runhaskell your-haskell-file.hs ``` -------------------------------- ### Install Streamlit Source: https://help.pythonanywhere.com/pages/Streamlit Install the Streamlit package within your activated virtual environment. ```bash pip install streamlit ``` -------------------------------- ### Install Module with Reduced Output Source: https://help.pythonanywhere.com/pages/InstallingNewModules Add the `-q` flag to your pip install command to suppress excessive output during installation, preventing console closure errors. ```bash pip install -q ``` -------------------------------- ### Install IPython for Enhanced Shell Source: https://help.pythonanywhere.com/pages/FollowingTheDjangoTutorial Install IPython for a better interactive interpreter experience with tab-completion and syntax highlighting in the manage.py shell. ```bash pip install ipython ``` -------------------------------- ### Setting up a Cabal Environment Source: https://help.pythonanywhere.com/pages/Haskell Commands to set up a Cabal environment, including updating package lists, installing `cabal-install`, and initializing a sandbox. ```bash # setup ~/.cabal and download latest package list from hackage.haskell.org cabal update # upgrade cabal-install, the CLI tool, to a shiny new version to get sandbox functionality cabal install cabal-install --jobs=5 # the newly updated cabal will live in ~/.cabal/bin/cabal; make sure you are using it echo "alias cabal=~/.cabal/bin/cabal" >> ~/.bashrc && source ~/.bashrc mkdir a-cool-haskell-project cd a-cool-haskell-project # setup a "virtualenv" cabal sandbox init # create your cabal package! cabal init ``` -------------------------------- ### Start Sharing a File Source: https://help.pythonanywhere.com/pages/API Initiates sharing for a file at the specified path. Returns 201 if sharing starts, or 200 if the file was already shared. ```http POST /api/v0/user/{username}/files/sharing/ path=path/to/your/file.txt ``` -------------------------------- ### Create a Virtual Environment and Install Django Source: https://help.pythonanywhere.com/pages/FollowingTheDjangoTutorial Use these commands in a Bash Console to create a virtual environment named 'django4' and install Django into it. Ensure your virtualenv is active when working on the Django tutorial. ```bash mkvirtualenv django4 --python=/usr/bin/python3.10 pip install django ``` -------------------------------- ### Setuptools Installation Error (SyntaxError) Source: https://help.pythonanywhere.com/pages/Python37VirtualenvOnInnit This traceback shows a SyntaxError related to setuptools, indicating an incompatibility with the Python 3.7 environment. ```text Traceback (most recent call last): File "", line 36, in File "", line 14, in File "/home/yourusername/.virtualenvs/myvirtualenv/lib/python3.7/site-packages/setuptools/__init__.py", line 18 sys.path.extend(((vendor_path := os.path.join(os.path.dirname(os.path.dirname(__file__)), 'setuptools', '_vendor')) not in sys.path) * [vendor_path]) # fmt: skip ^ SyntaxError: invalid syntax ``` -------------------------------- ### List Available Node.js Versions Source: https://help.pythonanywhere.com/pages/Node View a list of all available Node.js versions that can be installed using NVM. ```bash nvm ls-remote ``` -------------------------------- ### Install Jam.py using pip Source: https://help.pythonanywhere.com/pages/Jampy Install the Jam.py library for a specific Python version in a Bash console. ```bash pip3.7 install --user jam.py ``` -------------------------------- ### Install a Specific Node.js Version Source: https://help.pythonanywhere.com/pages/Node Install a particular version of Node.js. Replace 'v18.12.1' with the desired version. ```bash nvm install v18.12.1 ``` -------------------------------- ### Clone Flask-SocketIO Example Project Source: https://help.pythonanywhere.com/pages/FlaskSocketIO Clones the official Flask-SocketIO example project from GitHub. This provides a base for deployment. ```bash git clone https://github.com/miguelgrinberg/Flask-SocketIO.git ``` -------------------------------- ### Create Virtualenv and Install Django/Requirements Source: https://help.pythonanywhere.com/pages/DeployExistingDjangoProject Use this bash command to create a virtual environment for your Django project and install Django or other dependencies from a requirements file. ```bash $ mkvirtualenv --python=/usr/bin/python3.10 mysite-virtualenv (mysite-virtualenv)$ pip install django # or, if you have a requirements.txt: (mysite-virtualenv)$ pip install -r requirements.txt ``` -------------------------------- ### Install ASGI Requirements Source: https://help.pythonanywhere.com/pages/ASGIAPI Installs the 'requests', 'uvicorn' (with standard extras), and 'fastapi' packages into the active virtual environment. These are required for running ASGI applications. ```bash pip install requests "uvicorn[standard]" fastapi ``` -------------------------------- ### FastAPI Response Example Source: https://help.pythonanywhere.com/pages/ASGIAPI This is an example of the response you would receive when accessing the newly created website URL. It shows a simple "Hello from FastAPI" message, indicating that your FastAPI application is running correctly. ```text {"message":"Hello from FastAPI"} ``` -------------------------------- ### Download Sample Streamlit App Source: https://help.pythonanywhere.com/pages/Streamlit Download the example Streamlit application file from the official Streamlit demo repository. ```bash wget https://raw.githubusercontent.com/streamlit/demo-uber-nyc-pickups/master/streamlit_app.py ``` -------------------------------- ### Install PythonAnywhere Command-Line Tool Source: https://help.pythonanywhere.com/pages/ASGICommandLine Installs or upgrades the pythonanywhere command-line tool. This is a prerequisite for managing your ASGI site via the command line. ```bash pip install --upgrade pythonanywhere ``` -------------------------------- ### Install Playwright in a Virtual Environment Source: https://help.pythonanywhere.com/pages/Playwright Use this command to create a virtual environment and install Playwright. This is necessary because Playwright is not compatible with some pre-installed packages on PythonAnywhere. ```bash mkvirtualenv my-playwright-env --python=python3.10 pip install playwright ``` -------------------------------- ### Install Vue CLI Globally Source: https://help.pythonanywhere.com/pages/Vue Installs the Vue.js command-line interface globally on your system. This is a prerequisite for creating and managing Vue projects. ```sh npm install -g @vue/cli ``` -------------------------------- ### Create virtualenv and install Flask dependencies Source: https://help.pythonanywhere.com/pages/FlaskWithTheNewWebsiteSystem Create a virtual environment named 'my_venv' using Python 3.10 and install Flask, Gunicorn, and Eventlet within it. These are necessary for running the Flask application. ```bash mkvirtualenv my_venv --python=python3.10 ``` ```bash pip install flask gunicorn eventlet ``` -------------------------------- ### Install Custom SSL Certificate via Command Line Source: https://help.pythonanywhere.com/pages/HTTPSCustomCerts Uses the PythonAnywhere helper script to install a custom SSL certificate and private key for a specified web app. Replace placeholders with your actual domain and file paths. ```bash pa_install_webapp_ssl.py www.yourdomain.com /home/yourusername/something/combined-cert.pem /home/yourusername/something/private-key.pem ``` -------------------------------- ### Tornado WSGI Server Example (Do Not Use on PythonAnywhere) Source: https://help.pythonanywhere.com/pages/UsingTornado This example demonstrates how to create a WSGI server for a Tornado application. It is explicitly stated that this method should NOT be used on PythonAnywhere as it will break the web app. ```python server = wsgiref.simple_server.make_server('', 8888, application) server.serve_forever() ``` -------------------------------- ### Install IPython kernel for virtualenv Source: https://help.pythonanywhere.com/pages/IPythonNotebookVirtualenvs On 'haggis' or 'innit' system images, run this command to install a custom IPython kernel linked to your virtualenv. The kernel name must follow specific naming conventions. ```bash ipython kernel install --name "venv-name" --user ``` -------------------------------- ### Generate requirements.txt Source: https://help.pythonanywhere.com/pages/RebuildingVirtualenvs Create a requirements.txt file to record all installed packages in the current virtualenv. This is crucial for recreating the environment later. ```bash pip freeze > /tmp/requirements.txt ``` -------------------------------- ### Install virtualenvwrapper Source: https://help.pythonanywhere.com/pages/InstallingVirtualenvWrapper Add the virtualenvwrapper source command to your .bashrc file and then source it to make the commands available in the current session. ```bash echo '' >> ~/.bashrc && echo 'source virtualenvwrapper.sh' >> ~/.bashrc source virtualenvwrapper.sh ``` -------------------------------- ### Install TA-Lib Python Bindings Source: https://help.pythonanywhere.com/pages/TaLib Install the appropriate TA-Lib Python package version using pip. Ensure the version is compatible with the OS package by specifying a version constraint, for example, 'ta-lib<0.5'. Single quotes around the package name and version are crucial. ```bash pip install 'ta-lib<0.5' ``` -------------------------------- ### Basic Flask Database Setup in __main__ Source: https://help.pythonanywhere.com/pages/Flask This snippet shows a common way to set up database creation and run the Flask app within the __main__ clause. It's suitable for local development but requires adjustments for deployment platforms like PythonAnywhere. ```python if __name__ == '__main__': db.create_all() app.run() ``` -------------------------------- ### Basic CherryPy WSGI Application for PythonAnywhere Source: https://help.pythonanywhere.com/pages/UsingCherryPy This is a standard CherryPy application setup for PythonAnywhere. Replace the Root class with your own application logic. Ensure CherryPy is installed if using Python 3. ```python import sys sys.stdout = sys.stderr import atexit import cherrypy cherrypy.config.update({'environment': 'embedded'}) if cherrypy.__version__.startswith('3.0') and cherrypy.engine.state == 0: cherrypy.engine.start(blocking=False) atexit.register(cherrypy.engine.stop) class Root(object): def index(self): return 'Hello World!' index.exposed = True application = cherrypy.Application(Root(), script_name='', config=None) ``` -------------------------------- ### Django PostgreSQL Database Configuration Source: https://help.pythonanywhere.com/pages/PostgresGettingStarted Example configuration for Django projects to connect to a PostgreSQL database. Ensure the 'NAME', 'USER', 'PASSWORD', 'HOST', and 'PORT' values match your specific setup. ```python DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': 'myappdb', 'USER': 'myappuser', 'PASSWORD': 'a-nice-random-password', 'HOST': 'myusername-667.postgres.pythonanywhere-services.com', 'PORT': 10667, } } ``` -------------------------------- ### Install a package into the virtualenv Source: https://help.pythonanywhere.com/pages/VirtualEnvForWebsites Use 'pip install' within an activated virtualenv to install packages. You can specify a version number or install the latest version. ```bash (myvirtualenv) $ pip install django==1.7.1 # or flask, or whichever modules you want to use, optionally specifying a version number ``` -------------------------------- ### Install Django within a virtualenv Source: https://help.pythonanywhere.com/pages/VirtualEnvForNewerDjango Once the virtualenv is activated, use 'pip install' to install Django or any other required packages. ```bash pip install django ``` -------------------------------- ### Python SSH Tunnel for PostgreSQL Access Source: https://help.pythonanywhere.com/pages/AccessingPostgresFromOutsidePythonAnywhere Use this Python code snippet to establish an SSH tunnel to your PostgreSQL database on PythonAnywhere. Ensure you have the `sshtunnel` and `psycopg2` packages installed. Adjust the `postgres_hostname`, `postgres_host_port`, `ssh_username`, `ssh_password`, and database credentials to match your specific setup. The connection is managed within a context manager, and the database connection is closed afterward. ```python import psycopg2 import sshtunnel sshtunnel.SSH_TIMEOUT = 10.0 sshtunnel.TUNNEL_TIMEOUT = 10.0 postgres_hostname = "yourusername-1234.postgres.pythonanywhere-services.com" # You will have your own here postgres_host_port = 1234 # You will have your own port here with sshtunnel.SSHTunnelForwarder( ('ssh.pythonanywhere.com'), ssh_username='your PythonAnywhere username', ssh_password='the password you use to log in to the PythonAnywhere website', remote_bind_address=(postgres_hostname, postgres_host_port) ) as tunnel: connection = psycopg2.connect( user='a postgres user', password='password for the postgres user', host='127.0.0.1', port=tunnel.local_bind_port, database='your database name', ) # Do stuff inside the context manager block connection.close() ``` -------------------------------- ### Create an ASGI Website Source: https://help.pythonanywhere.com/pages/ASGICommandLine Use this command to create a new ASGI website, specifying the domain and the framework-specific command to run. ```bash pa website create --domain YOURUSERNAME.pythonanywhere.com --command 'COMMAND' ``` -------------------------------- ### HTML Example for Static Assets Source: https://help.pythonanywhere.com/pages/StaticFiles Illustrates how to reference static assets within an HTML template using a base URL path. ```html [...] ``` -------------------------------- ### Create Virtual Environment with Full Path Source: https://help.pythonanywhere.com/pages/VirtualenvsExplained Alternatively, you can explicitly provide the full path to the Python executable when creating a virtual environment to ensure it's set up correctly, especially in environments like `innit`. ```bash mkvirtualenv -p /usr/local/bin/python3.11 venv ``` -------------------------------- ### Connecting to SFTP via command-line Source: https://help.pythonanywhere.com/pages/UploadingAndDownloadingFiles Use this command to initiate an SFTP connection from the command line. Replace placeholders with your username and the appropriate SSH server hostname. ```bash sftp @ ``` -------------------------------- ### Create Mezzanine Database Source: https://help.pythonanywhere.com/pages/HowtouseMezzanineonPythonAnywhere Initialize the database for your Mezzanine project using the manage.py command. ```python python manage.py createdb --noinput ``` -------------------------------- ### GET /api/v1/user/{username}/websites/{domain_name}/ Source: https://help.pythonanywhere.com/pages/API Get information about a specific domain and its webapp in JSON format. ```APIDOC ## GET /api/v1/user/{username}/websites/{domain_name}/ ### Description Get information about the domain and its webapp in json format. ### Method GET ### Endpoint /api/v1/user/{username}/websites/{domain_name}/ ### Parameters #### Path Parameters - **username** (str) - Required - The username of the account. - **domain_name** (str) - Required - The domain name of the website. ``` -------------------------------- ### Verify Django installation and version Source: https://help.pythonanywhere.com/pages/VirtualEnvForNewerDjango Check that 'django-admin' is accessible within the virtualenv and verify the installed Django version. ```bash which django-admin django-admin --version ``` -------------------------------- ### Example Postgres DiskFull Error Source: https://help.pythonanywhere.com/pages/PostgresSharedMemory This is an example of the error message you might encounter when Postgres runs out of shared memory. ```sql psycopg2.errors.DiskFull: could not resize shared memory segment "/PostgreSQL.230765310" to 8388608 bytes: No space left on device ``` -------------------------------- ### Create a new Flask website Source: https://help.pythonanywhere.com/pages/FlaskWithTheNewWebsiteSystem Use this command to create a new website, specifying the domain and the command to run your web application. Replace YOURUSERNAME and mysite with your actual username and project directory. ```bash pa website create --domain YOURUSERNAME.pythonanywhere.com --command '/home/YOURUSERNAME/.virtualenvs/my_venv/bin/gunicorn --worker-class eventlet -w 1 --chdir /home/YOURUSERNAME/mysite --bind unix:${DOMAIN_SOCKET} flask_app:app' ``` -------------------------------- ### Custom Bash Console with Setup Script Source: https://help.pythonanywhere.com/pages/TypesOfConsoles This bash script sets up a custom console by sourcing .bashrc, changing directory, and displaying git status. Make the script executable before use. ```bash #!/bin/bash --init-file source ~/.bashrc cd MyProjectDir git status ``` -------------------------------- ### Adding a Second SQL Server Configuration to .freetds.conf Source: https://help.pythonanywhere.com/pages/MSSQLServer This example shows how to add configuration for a second SQL Server instance to the `.freetds.conf` file. A new block with a unique server name and updated host/port is added. ```ini [sqlserver] host = YOUR_ORIGINAL_SQL_SERVER_IP_ADDRESS port = YOUR_ORIGINAL_SQL_SERVER_PORT tds version = 7.0 [secondsqlserver] host = YOUR_NEW_SQL_SERVER_IP_ADDRESS port = YOUR_NEW_SQL_SERVER_PORT tds version = 7.0 ``` -------------------------------- ### Start web2py in interactive console mode Source: https://help.pythonanywhere.com/pages/MigatingWeb2pyFromSQLiteToMySQL Starts the web2py application in interactive console mode for performing database operations. ```bash python web2py.py -S your_app_name -M -- P ``` -------------------------------- ### Get Scheduled Task Details (GET) Source: https://help.pythonanywhere.com/pages/API Retrieve specific information about a scheduled task using its ID. No parameters are required. ```bash curl https://www.pythonanywhere.com/api/v0/user/{{username}}/schedule/{{id}}/ ``` -------------------------------- ### Switch to a virtual environment Source: https://help.pythonanywhere.com/pages/VirtualEnvForNewerDjango Use the 'workon' command to activate your specific virtual environment for project development. ```bash 17:02 ~ $ workon myproject ``` -------------------------------- ### Check Vue CLI Version Source: https://help.pythonanywhere.com/pages/Vue Verifies that the Vue CLI has been installed correctly by displaying its version number. This is a sanity check after installation. ```sh vue --version ``` -------------------------------- ### Running a Custom Management Command with Virtualenv (Bash) Source: https://help.pythonanywhere.com/pages/DjangoManagementCommands Demonstrates activating a virtual environment named 'myenv' and then running a custom Django management command. ```bash workon myenv; ~/mysite/manage.py delete_old_comments ``` -------------------------------- ### Pip Installation Error (SyntaxError) Source: https://help.pythonanywhere.com/pages/Python37VirtualenvOnInnit This traceback indicates a SyntaxError, likely due to an incompatible version of pip being installed for Python 3.7. ```text Traceback (most recent call last): File "/home/yourusername/.virtualenvs/myvirtualenv/bin/pip", line 5, in from pip._internal.cli.main import main File "/home/yourusername/.virtualenvs/myvirtualenv/lib/python3.7/site-packages/pip/_internal/cli/main.py", line 11, in from pip._internal.cli.autocompletion import autocomplete File "/home/yourusername/.virtualenvs/myvirtualenv/lib/python3.7/site-packages/pip/_internal/cli/autocompletion.py", line 10, in from pip._internal.cli.main_parser import create_main_parser File "/home/yourusername/.virtualenvs/myvirtualenv/lib/python3.7/site-packages/pip/_internal/cli/main_parser.py", line 9, in from pip._internal.build_env import get_runnable_pip File "/home/yourusername/.virtualenvs/myvirtualenv/lib/python3.7/site-packages/pip/_internal/build_env.py", line 18, in from pip._internal.cli.spinners import open_spinner File "/home/yourusername/.virtualenvs/myvirtualenv/lib/python3.7/site-packages/pip/_internal/cli/spinners.py", line 9, in from pip._internal.utils.logging import get_indentation File "/home/yourusername/.virtualenvs/myvirtualenv/lib/python3.7/site-packages/pip/_internal/utils/logging.py", line 13, in from pip._vendor.rich.console import ( File "/home/yourusername/.virtualenvs/myvirtualenv/lib/python3.7/site-packages/pip/_vendor/rich/console.py", line 41, in from pip._vendor.typing_extensions import ( File "/home/yourusername/.virtualenvs/myvirtualenv/lib/python3.7/site-packages/pip/_vendor/typing_extensions.py", line 1039 def TypedDict(typename, fields=_marker, /, *, total=True, closed=False, **kwargs): ^ SyntaxError: invalid syntax ``` -------------------------------- ### Create .env file with environment variables Source: https://help.pythonanywhere.com/pages/EnvironmentVariables Use this command to create a .env file in your project directory and add environment variables to it. This is useful for storing configuration that varies between platforms. ```bash cd ~/my-project-dir echo "export SECRET_KEY=sekritvalue" >> .env echo "export OTHER_SECRET=somethingelse" >> .env # etc ``` -------------------------------- ### Create Virtual Environment with PATH Precedence Source: https://help.pythonanywhere.com/pages/VirtualenvsExplained To avoid issues with symlinks in the `innit` system image, ensure `/usr/local/bin` is on your PATH before `/usr/bin`. This allows `mkvirtualenv` to correctly create the virtual environment using the specified Python version. ```bash mkvirtualenv -p python3.11 venv ``` -------------------------------- ### Install python-dotenv Source: https://help.pythonanywhere.com/pages/EnvironmentVariables Install the python-dotenv package into your virtual environment or globally. Ensure you have version 0.8 or higher for proper .env file parsing. ```bash workon my-virtualenv-name pip install python-dotenv # or, if you're not using a virtualenv: pip3.6 install --user python-dotenv # and, optionally, add it to your requirements.txt, if you're using one: echo python-dotenv >> requirements.txt ``` -------------------------------- ### POST /api/v1/user/{username}/websites/ Source: https://help.pythonanywhere.com/pages/API Create a new domain and associated webapp. Returns information about the created website in JSON format. ```APIDOC ## POST /api/v1/user/{username}/websites/ ### Description Create a new domain and associated webapp. Returns information about created website (domain with webapp) in json format. ### Method POST ### Endpoint /api/v1/user/{username}/websites/ ### Parameters #### Path Parameters - **username** (str) - Required - The username of the account. #### Request Body - **domain_name** (str) - Required - The desired domain name. - **enabled** (bool) - Optional - Whether the website should be enabled. - **webapp** (object) - Optional - Webapp configuration details. ``` -------------------------------- ### Install Selenium with Specific Version (Bash) Source: https://help.pythonanywhere.com/pages/Selenium Use this command in a Bash console to install a specific version of Selenium, recommended for compatibility with your system image. ```bash pip3.10 install --user selenium==4.26.1 ``` -------------------------------- ### Create a Virtual Environment Source: https://help.pythonanywhere.com/pages/VirtualenvsExplained Use the `mkvirtualenv` command to create a new virtual environment. Specify the desired Python version using the `--python` flag. The virtual environment will be created in the `.virtualenvs` directory in your home folder. ```bash mkvirtualenv myvirtualenv --python=python3.13 ``` -------------------------------- ### Display Django project structure Source: https://help.pythonanywhere.com/pages/VirtualEnvForNewerDjango Use the 'tree' command to visualize the directory structure of the newly created Django project. ```bash tree mysite ``` -------------------------------- ### Install PythonAnywhere Helper Scripts Source: https://help.pythonanywhere.com/pages/HTTPSCustomCerts Installs or upgrades the PythonAnywhere helper scripts using pip. Ensure you are in a new Bash console for API access. ```bash pip3.7 install --user --upgrade pythonanywhere ``` -------------------------------- ### Create a Mezzanine Project Source: https://help.pythonanywhere.com/pages/HowtouseMezzanineonPythonAnywhere Generate a new Mezzanine project with the specified project name. ```bash workon mezzanine mezzanine-project project_name cd project_name ``` -------------------------------- ### Install Flask-SocketIO Dependencies Source: https://help.pythonanywhere.com/pages/FlaskSocketIO Installs the necessary Python packages (Flask-SocketIO, Gunicorn, eventlet) into the active virtual environment. These are required for running a Flask-SocketIO application. ```bash pip install flask-socketio gunicorn eventlet ``` -------------------------------- ### List Installed Fonts Source: https://help.pythonanywhere.com/pages/Fonts Run this command in a Bash console to see a list of fonts installed on the system. The name before the colon is the font's identifier. ```bash fc-list : family style spacing ``` -------------------------------- ### Create a New Website Source: https://help.pythonanywhere.com/pages/API Use this endpoint to create a new domain and its associated web application. The response includes detailed information about the created website, including its webapp and logfile paths. ```json { "id": , "user": , "domain_name": , "enabled": , "webapp": { "id": , "command": , "domains": [{"domain_name": , "enabled": }] }, "logfiles": { "access": , "server": , "error": } } ``` -------------------------------- ### Create Webapp with Manual Configuration Source: https://help.pythonanywhere.com/pages/API Creates a new web application. Requires specifying the domain name and Python version (e.g., "python310"). ```http POST /api/v0/user/{username}/webapps/ ``` -------------------------------- ### Install Package for Specific Python Version Source: https://help.pythonanywhere.com/pages/DebuggingImportError Install a package using pip, specifying the Python version. This ensures the package is available for that specific version. ```bash pip3.8 install --user foo ``` -------------------------------- ### Django Comment Model Example Source: https://help.pythonanywhere.com/pages/DjangoManagementCommands Defines a Django model for comments, including user, timestamp, and text fields. This is a prerequisite for the management command example. ```python class Comment(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) timestamp = models.DateTimeField(auto_now_add=True) text = models.TextField(max_length=1024) ``` -------------------------------- ### Install Jupyter into virtualenv Source: https://help.pythonanywhere.com/pages/IPythonNotebookVirtualenvs Activate your virtualenv and install the Jupyter package with the specific version identified in the previous step. This ensures your notebook uses the correct dependencies. ```bash workon my-virtualenv-name # activate your virtualenv, if you haven't already pip install jupyter== ``` -------------------------------- ### Custom Console for Virtual Environment Source: https://help.pythonanywhere.com/pages/TypesOfConsoles Use this command to start an IPython shell with a specific virtual environment activated. Ensure virtualenvwrapper is sourced and the virtual environment name is correct. ```bash source virtualenvwrapper.sh && workon my_venv && ipython ``` -------------------------------- ### Check Django Installation Version Source: https://help.pythonanywhere.com/pages/FollowingTheDjangoTutorial Run this command to verify that Django is installed correctly and to check its version. If a version lower than 4.1 is shown, your virtualenv might not be active. ```sh python -m django --version ``` -------------------------------- ### Show Jupyter package version Source: https://help.pythonanywhere.com/pages/IPythonNotebookVirtualenvs Use this command to find the installed version of the Jupyter package for a specific Python version. This is needed to install the correct version into your virtualenv. ```bash pip3.10 show jupyter ``` -------------------------------- ### Install Module within a Virtual Environment Source: https://help.pythonanywhere.com/pages/InstallingNewModules Once inside an activated virtual environment, use this command to install Python modules. The `--user` flag is not needed and will cause an error. ```bash (my-virtualenv) $ pip install pwhich ``` -------------------------------- ### Create Production Build for React App Source: https://help.pythonanywhere.com/pages/React Navigate into the React application directory and run npm run build to generate production-ready static assets. These assets will be served by your Python backend. ```sh cd frontend npm run build ```