Installing P4 API for Python
Before installing P4 API for Python, any previously installed versions should be uninstalled.
In this section:
Install P4 API for Python using pip
As of
P4 API for Python
2015.1, the recommended mechanism for installing
P4 API for Python
is via pip
. For example:
pip install p4python
pip installs binary versions of P4 API for Python where possible, otherwise it attempts to automatically build P4 API for Python from source. For instruction on building P4 API for Python from source, see the Building P4 API for Python from Source section of the P4 API for Python Release notes.
When P4 API for Python is built without the --apidir option, setup attempts to connect to the Perforce website to download the correct version of the P4 API for C/C++ binary. If the P4 API for C/C++ download is successful, it is unpacked into a temporary directory.
Linux: when P4 API for Python is built without the --ssl option, setup.py looks at the installed OpenSSL and checks to see if it is a supported version.
P4 API for Python 2019.1 and later: OpenSSL libraries are REQUIRED, version 1.0.2+ or version 1.1.1+. If a supported version of OpenSSL is not found, setup.py will download and install one from ftp.openssl.org.
Install P4 API for Python from a package
-
Configure the Perforce package repository.
As root, follow the instructions for your OS distribution:
Ubuntu 20.04:
Create the file
/etc/apt/sources.list.d/perforce.list
with the following content:deb http://package.perforce.com/apt/ubuntu/ focal release
Ubuntu 22.04:
Create the file
/etc/apt/sources.list.d/perforce.list
with the following content:deb http://package.perforce.com/apt/ubuntu/ jammy release
Ubuntu 24.04:
Create the file
/etc/apt/sources.list.d/perforce.list
with the following content:deb http://package.perforce.com/apt/ubuntu/ noble release
RHEL 8/Rocky Linux 8:
Create the file
/etc/yum.repos.d/perforce.repo
with the following content:[Perforce]
name=Perforce
baseurl=http://package.perforce.com/yum/rhel/8/x86_64/
enabled=1
gpgcheck=1RHEL 9/Rocky Linux 9:
Create the file
/etc/yum.repos.d/perforce.repo
with the following content:[Perforce]
name=Perforce
baseurl=http://package.perforce.com/yum/rhel/9/x86_64/
enabled=1
gpgcheck=1 -
Import the Perforce package signing key.
Follow the instructions for your OS distribution:
Ubuntu:
wget -qO - https://package.perforce.com/perforce.pubkey | sudo apt-key add -
sudo apt-get update
RHEL/Rocky Linux:
sudo rpm --import https://package.perforce.com/perforce.pubkey
For information about how to verify the authenticity of the signing key, see the Perforce website
-
Install the P4 API for Python package on the server hosting the P4 Server.
Follow the instructions for your OS distribution:
Ubuntu:
Install the correct package for the version of Python that you are using, for example:
For an OS default Python3 version:
sudo apt install perforce-p4python3
or
For a specific version supported by the OS:
sudo apt install perforce-p4python3-python3.10
sudo apt install perforce-p4python3-python3.9
RHEL/Rocky Linux:
Install the correct package for the version of Python that you are using, for example:
For an OS default Python3 version:
sudo yum install perforce-p4python3
or
For a specific version supported by the OS:
sudo yum install perforce-p4python3-python3.8
sudo yum install perforce-p4python3-python3.9