Install Python 3.x on CentOS/RHEL 7/6

Giang Trung
1 min readJul 16, 2020

--

Step 1: Download python on official site, unz

# wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tgz
# tar -xzf Python-3.6.8.tgz

Step 2: Install Python

#cd Python-3.6.8

# ./configure --enable-optimizations --enable-shared make sudo

# make altinstall

Step 3: Set link to user environment

# sudo ln -s /usr/local/bin/python3.6 /usr/bin/python3

Step 4: Check python version

# python3 --version

# which python3

Step 5: Using

# python3 xxx.py

Step 6 : A Python Program

  • Open Pycharm > New project > New .py file >
import json
from datetime import datetime, timedelta

import jwt
from flask import Response

private_key_str = open('jwtRS256.key').read()

def generate_token():
token = encode_auth_token('''forever''')
print(token)
x = json.dumps({
'error_code': 0,
'message': 'generate token success',
'data': {
'token': token.decode('utf-8')
}
})
print(x)


def encode_auth_token(data):
"""
Generates the Auth Token
:return: string
"""
try:
payload = {
'exp': datetime.utcnow() + timedelta(days=3650),
'iat': datetime.utcnow(),
'sub': data,
'name': ''
}
return jwt.encode(
payload,
private_key_str,
algorithm='RS256'
)
except Exception as e:
return e


generate_token()
  • Config build point to main .py file (D:\Python\CreateToken.py)
  • Add lib : New requirements.txt with (cryptography) > Click install plugins
  • Add jwtRS256.key to project
  • Run >>

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Giang Trung
Giang Trung

No responses yet

Write a response