How to install Python packages with pip and requirements.txt

Install packages in the correct environment

Each Python application has its own virtual environment. Packages must be installed inside that environment.

Its path follows this pattern:

/home/USERNAME/virtualenv/APPROOT/VERSION/

Do not install packages globally or use sudo.

The application screen displays the exact activation command for your app. Copy that command instead of typing the path manually.

Install from requirements.txt in the app screen

  1. Upload requirements.txt to your application root.
  2. Open your Python application in the app manager (cPanel: Software → Setup Python App).
  3. Find Configuration files.
  4. Add requirements.txt.
  5. Select Run Pip Install.
  6. Wait for the installation to finish.
  7. Review any error shown by the installer.
  8. Restart the application.

A simple requirements.txt might contain:

Flask==3.1.0
mysqlclient==2.2.7
python-dotenv==1.0.1

Use versions that are compatible with the Python version selected for your application.

Install from requirements.txt over SSH

  1. Connect to your hosting account over SSH.
  2. Open the application screen in your control panel.
  3. Copy its virtual-environment activation command.
  4. Run that command in your SSH session.
  5. Change to the application root.
  6. Install the requirements.

For example:

source /home/USERNAME/virtualenv/APPROOT/VERSION/bin/activate
cd /home/USERNAME/APPROOT
python -m pip install -r requirements.txt

Replace all uppercase placeholders with the values shown for your application.

Install one package over SSH

After activating the application's virtual environment, run:

python -m pip install PACKAGE_NAME

For example:

python -m pip install flask

Add the package to requirements.txt as well. This makes the application easier to rebuild or move later.

Check whether a package is installed

Activate the virtual environment and run:

python -m pip show PACKAGE_NAME

To list all installed packages:

python -m pip list

If package installation fails

Read the complete pip error before trying again.

Common causes include:

  • The package does not support your selected Python version.
  • A required package version does not exist.
  • The package needs a system library or compiler that is unavailable on shared hosting.
  • The package name is misspelt.
  • You installed it outside the application's virtual environment.
  • Two packages require incompatible dependency versions.

Do not use sudo or attempt to modify server packages. Contact Webway Support if a dependency requires a system-level library.

Restart the application

Restart the application after installing, removing or upgrading packages:

  1. Return to the Python application screen.
  2. Select Restart.
  3. Open the application and test it again.

Did this answer it?