Sample code for 30+ languages & platforms
Chilkat2-Python

Duplicate openssl pkey -in private.pem -pubout -out pubkey.pem

See more OpenSSL Examples

How to output the public part of a private key: Demonstrates how to duplicate this OpenSSL command:
openssl pkey -in private.pem -pubout -out pubkey.pem

Chilkat Chilkat2-Python Downloads

Chilkat2-Python
import sys
import chilkat2

success = False

pkey = chilkat2.PrivateKey()

# Load the private key from an PEM file:
success = pkey.LoadPemFile("private.pem")
if (success == False):
    print(pkey.LastErrorText)
    sys.exit()

pubKey = chilkat2.PublicKey()
pkey.ToPublicKey(pubKey)

success = pubKey.SavePemFile(False,"pubKey.pem")
if (success != True):
    print(pubKey.LastErrorText)

    sys.exit()

print("Success.")