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
- Upload
requirements.txtto your application root. - Open your Python application in the app manager (cPanel: Software → Setup Python App).
- Find Configuration files.
- Add
requirements.txt. - Select Run Pip Install.
- Wait for the installation to finish.
- Review any error shown by the installer.
- 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
- Connect to your hosting account over SSH.
- Open the application screen in your control panel.
- Copy its virtual-environment activation command.
- Run that command in your SSH session.
- Change to the application root.
- 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:
- Return to the Python application screen.
- Select Restart.
- Open the application and test it again.
Did this answer it?