0% found this document useful (0 votes)
6 views

1. Setup ReactJS,PythonFlash Environment on OEL8

This document provides a step-by-step guide for installing Python 3.10.4 and setting up a Flask application on Oracle Linux 8. It includes instructions for installing required dependencies, creating a virtual environment, and configuring a React application with Node.js and necessary packages. Additionally, it covers commands to run the Flask app and manage dependencies.

Uploaded by

imsharfi92
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

1. Setup ReactJS,PythonFlash Environment on OEL8

This document provides a step-by-step guide for installing Python 3.10.4 and setting up a Flask application on Oracle Linux 8. It includes instructions for installing required dependencies, creating a virtual environment, and configuring a React application with Node.js and necessary packages. Additionally, it covers commands to run the Flask app and manage dependencies.

Uploaded by

imsharfi92
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Step 1 – Install Required Dependencies

The latest version of Python is not included in the Oracle Linux 8 default repo, so you will need to
compile it from the source.
To compile Python from the source, you will need to install some dependencies on your system. You can
install all of them by running the following command:
[oracle@dockerhost1 ~]$ sudo dnf update
[oracle@dockerhost1 ~]$ dnf install curl gcc openssl-devel bzip2-devel libffi-devel zlib-devel wget make -y

once all the dependencies are installed, you can proceed to the next step.

Step 2 – Install Python 3.10.4 on Oracle Linux 8

Next, visit the Python official download page and download the latest version of Python using the
following command:

[oracle@dockerhost1 ~]$ wget https://www.python.org/ftp/python/3.10.4/Python-3.10.4.tgz

Once the download is completed, extract the downloaded file using the following command:
[oracle@dockerhost1 ~]$ tar -xf Python-3.10.4.tgz

Next, change the directory to the extracted directory and configure Python using the following
command:

[oracle@dockerhost1 ~]$ cd Python-3.10.4


[oracle@dockerhost1 Python-3.10.4]$ ./configure --enable-optimizations

Next, start the build process using the following command:

[oracle@dockerhost1 Python-3.10.4]$ make -j 2


[oracle@dockerhost1 Python-3.10.4]$ nproc

Finally, install Python 3.10 by running the following command:


[oracle@dockerhost1 Python-3.10.4]$ sudo make altinstall

After the successful installation, verify the Python installation using the following command:
[oracle@dockerhost1 Python-3.10.4]$ python3.10 --version
Python 3.10.4
Step 3 – Create a Virtual Environment in Python

Python provides a venv module that helps developers to create a virtual environment and deploy
applications easily in an isolated environment.

To create a virtual environment named python-env, run the following command:


[oracle@dockerhost1 Python-3.10.4]$ python3.10 -m venv python-env

Next, activate the virtual environment using the following command:


[oracle@dockerhost1 Python-3.10.4]$ source python-env/bin/activate

You will get the following shell:


(python-env) [oracle@dockerhost1 Python-3.10.4]$

For example, run the following command to install apache-airflow:

pip3.10 install apache-airflow

If you want to remove this package, run the command below:

pip3.10 uninstall apache-airflow

To exit from the Python virtual environment, run the following command:

deactivate
Step#4: Install Python 3 and the flask , cx_Oracle, Jinga2 & six packages on Oracle Linux 8

First pre-requisite is to ensure your instance has Python3 installed along with the Python
packages. We will also install the command-line browser links to test the API using a html form.

$ pip3.10 install flask

$ pip3.10 install cx_Oracle

$ pip3.10 install six

$ pip3.10 install Jinja2


$ pip install flask

mkdir flask-app

vi app.py

# app.py
from flask import Flask

app = Flask(__name__)

@app.route("/")
def hello():
return "<h1>Hello, World!</h1>"

if __name__ == "__main__":
app.run(debug=True)
Correct Command:

bash
Copy
flask run

Important Notes:
1. Flask needs to know which Python file contains your application. By default, it looks
for app.py or wsgi.py. If your main file has a different name (e.g., myapp.py), you need to
set the FLASK_APP environment variable first:

bash

Copy

export FLASK_APP=app.py # Linux/Mac


# or
set FLASK_APP=app.py # Windows CMD
# or
$env:FLASK_APP = "app.py" # Windows PowerShell
2. Make sure you're in the correct directory where your Flask application exists.
3. If you want to run in development mode (with auto-reloader):
bash

Copy
export FLASK_ENV=development # Linux/Mac
# or
set FLASK_ENV=development # Windows CMD
# or
$env:FLASK_ENV = "development" # Windows PowerShell
flask run
4. If you want to specify a different port:
bash

Copy

flask run --port 5001

Alternative (direct Python execution):


If you prefer, you can also run your Flask app directly with Python:

bash
Copy
python app.py

(assuming your app.py has the standard if __name__ == '__main__': app.run() block at the bottom)

(+)
(python-env) [oracle@dockerhost1 flask-app]$ pip install flask flask-cors cx_Oracle python-
dotenv

Requirement already satisfied: flask in /home/oracle/python-env/lib/python3.10/site-packages (3.1.0)

Collecting flask-cors

Downloading flask_cors-5.0.1-py3-none-any.whl (11 kB)

Requirement already satisfied: cx_Oracle in /home/oracle/python-env/lib/python3.10/site-packages (8.3.0)

Collecting python-dotenv

Downloading python_dotenv-1.1.0-py3-none-any.whl (20 kB)

Requirement already satisfied: itsdangerous>=2.2 in /home/oracle/python-env/lib/python3.10/site-packages (from flask) (2.2.0)

Requirement already satisfied: Jinja2>=3.1.2 in /home/oracle/python-env/lib/python3.10/site-packages (from flask) (3.1.6)

Requirement already satisfied: click>=8.1.3 in /home/oracle/python-env/lib/python3.10/site-packages (from flask) (8.1.8)

Requirement already satisfied: blinker>=1.9 in /home/oracle/python-env/lib/python3.10/site-packages (from flask) (1.9.0)

Requirement already satisfied: Werkzeug>=3.1 in /home/oracle/python-env/lib/python3.10/site-packages (from flask) (3.1.3)

Requirement already satisfied: MarkupSafe>=2.0 in /home/oracle/python-env/lib/python3.10/site-packages (from Jinja2>=3.1.2-


>flask) (3.0.2)

Installing collected packages: python-dotenv, flask-cors

Successfully installed flask-cors-5.0.1 python-dotenv-1.1.0

WARNING: You are using pip version 22.0.4; however, version 25.0.1 is available.

You should consider upgrading via the '/home/oracle/python-env/bin/python3.10 -m pip install --upgrade pip' command.

(python-env) [oracle@dockerhost1 flask-app]$

Running flask application:


(python-env) [oracle@dockerhost1 flask-app]$ flask run

(python-env) [oracle@dockerhost1 flask-app]$ python app.py


To begin, please enter the following into your CLI.

[oracle@dockerhost1 ~]$ python3.10 -m venv python-env


[oracle@dockerhost1 ~]$ source python-env/bin/activate
[oracle@dockerhost1 ~]$ deactivate
Configuring React JS:

(python-env) [oracle@dockerhost1 flask-app]$ sudo dnf install nodejs -y

Last metadata expiration check: 1:22:59 ago on Tue 01 Apr 2025 02:28:47 PM GMT.
Dependencies resolved.
========================================================================================================
=====================================================
Package Architecture Version Repository Size
========================================================================================================
=====================================================
Installing:
nodejs x86_64 1:10.24.0-1.module+el8.3.0+9671+154373c8 ol8_appstream 8.8 M
Installing dependencies:
npm x86_64 1:6.14.11-1.10.24.0.1.module+el8.3.0+9671+154373c8 ol8_appstream
3.7 M
Installing weak dependencies:
nodejs-full-i18n x86_64 1:10.24.0-1.module+el8.3.0+9671+154373c8 ol8_appstream
7.3 M
Enabling module streams:
nodejs 10
Transaction Summary
========================================================================================================
=====================================================
Install 3 Packages
Total download size: 20 M
Installed size: 71 M
Downloading Packages:
(1/3): nodejs-full-i18n-10.24.0-1.module+el8.3.0+9671+154373c8.x86_64.rpm 4.1 MB/s | 7.3 MB
00:01
(2/3): nodejs-10.24.0-1.module+el8.3.0+9671+154373c8.x86_64.rpm 3.7 MB/s | 8.8 MB
00:02
(3/3): npm-6.14.11-1.10.24.0.1.module+el8.3.0+9671+154373c8.x86_64.rpm 1.5 MB/s | 3.7 MB
00:02
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 8.0 MB/s | 20 MB 00:02
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Running scriptlet: npm-1:6.14.11-1.10.24.0.1.module+el8.3.0+9671+154373c8.x86_64
1/1
Preparing : 1/1
Installing : nodejs-full-i18n-1:10.24.0-1.module+el8.3.0+9671+154373c8.x86_64 1/3
Installing : npm-1:6.14.11-1.10.24.0.1.module+el8.3.0+9671+154373c8.x86_64 2/3
Installing : nodejs-1:10.24.0-1.module+el8.3.0+9671+154373c8.x86_64 3/3
Running scriptlet: nodejs-1:10.24.0-1.module+el8.3.0+9671+154373c8.x86_64 3/3
Verifying : nodejs-1:10.24.0-1.module+el8.3.0+9671+154373c8.x86_64 1/3
Verifying : nodejs-full-i18n-1:10.24.0-1.module+el8.3.0+9671+154373c8.x86_64 2/3
Verifying : npm-1:6.14.11-1.10.24.0.1.module+el8.3.0+9671+154373c8.x86_64 3/3

Installed:
nodejs-1:10.24.0-1.module+el8.3.0+9671+154373c8.x86_64 nodejs-full-i18n-1:10.24.0-
1.module+el8.3.0+9671+154373c8.x86_64
npm-1:6.14.11-1.10.24.0.1.module+el8.3.0+9671+154373c8.x86_64

Complete!
Once Node.js is installed, you can verify the Node.js version using the following command:

node --version

v10.24.0

To verify the NPM version, run the following command:

npm -v
6.14.11

Install React dependencies:

npm install axios @mui/material @emotion/react @emotion/styled

(python-env) [oracle@dockerhost1 flask-app]$ npm install axios @mui/material @emotion/react @emotion/styled


npm WARN saveError ENOENT: no such file or directory, open '/home/oracle/flask-app/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN notsup Unsupported engine for @mui/[email protected]: wanted: {"node":">=14.0.0"} (current:
{"node":"10.24.0","npm":"6.14.11"})
npm WARN notsup Not compatible with your version of node/npm: @mui/[email protected]
npm WARN notsup Unsupported engine for @mui/[email protected]: wanted: {"node":">=14.0.0"} (current:
{"node":"10.24.0","npm":"6.14.11"})
npm WARN notsup Not compatible with your version of node/npm: @mui/[email protected]
npm WARN notsup Unsupported engine for @mui/[email protected]: wanted: {"node":">=14.0.0"} (current:
{"node":"10.24.0","npm":"6.14.11"})
npm WARN notsup Not compatible with your version of node/npm: @mui/[email protected]
npm WARN notsup Unsupported engine for @mui/[email protected]: wanted: {"node":">=14.0.0"} (current:
{"node":"10.24.0","npm":"6.14.11"})
npm WARN notsup Not compatible with your version of node/npm: @mui/[email protected]
npm WARN notsup Unsupported engine for @mui/[email protected]: wanted: {"node":">=14.0.0"} (current:
{"node":"10.24.0","npm":"6.14.11"})
npm WARN notsup Not compatible with your version of node/npm: @mui/[email protected]
npm WARN enoent ENOENT: no such file or directory, open '/home/oracle/flask-app/package.json'
npm WARN @emotion/[email protected] requires a peer of react@>=16.8.0 but none is installed. You must install peer
dependencies yourself.
npm WARN @emotion/[email protected] requires a peer of react@>=16.8.0 but none is installed. You must install peer
dependencies yourself.
npm WARN @mui/[email protected] requires a peer of react@^17.0.0 || ^18.0.0 || ^19.0.0 but none is installed. You must install
peer dependencies yourself.
npm WARN @mui/[email protected] requires a peer of react-dom@^17.0.0 || ^18.0.0 || ^19.0.0 but none is installed. You must
install peer dependencies yourself.
npm WARN @emotion/[email protected] requires a peer of react@>=16.8.0 but none is installed. You
must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react@>=16.6.0 but none is installed. You must install peer
dependencies yourself.
npm WARN [email protected] requires a peer of react-dom@>=16.6.0 but none is installed. You must install peer
dependencies yourself.
npm WARN @types/[email protected] requires a peer of @types/react@* but none is installed. You must install
peer dependencies yourself.
npm WARN @mui/[email protected] requires a peer of react@^17.0.0 || ^18.0.0 || ^19.0.0 but none is installed. You must install
peer dependencies yourself.
npm WARN @mui/[email protected] requires a peer of react@^17.0.0 || ^18.0.0 || ^19.0.0 but none is installed. You must install
peer dependencies yourself.
npm WARN @mui/[email protected] requires a peer of react@^17.0.0 || ^18.0.0 || ^19.0.0 but none is installed. You
must install peer dependencies yourself.
npm WARN @mui/[email protected] requires a peer of react@^17.0.0 || ^18.0.0 || ^19.0.0 but none is installed. You must
install peer dependencies yourself.
npm WARN flask-app No description
npm WARN flask-app No repository field.
npm WARN flask-app No README data
npm WARN flask-app No license field.

+ @emotion/[email protected]
+ @emotion/[email protected]
+ @mui/[email protected]
+ [email protected]
added 102 packages from 108 contributors and audited 102 packages in 41.802s

19 packages are looking for funding


run `npm fund` for details

found 0 vulnerabilities
Reference followed:
https://www.atlantic.net/dedicated-server-hosting/how-to-install-node-js-and-npm-on-oracle-linux/

Connecting OracleDB with NodeJS on Oracle Linux 8


https://dev.to/farisdurrani/connecting-oracledb-with-nodejs-on-oracle-linux-8-1phm
Referrence followin:
https://www.atlantic.net/dedicated-server-hosting/how-to-install-python-3-10-on-oracle-linux/

Develop REST API’s for Oracle Database with Python 3 and Flask
https://medium.com/oracledevs/develop-rest-apis-for-oracle-database-with-python-3-and-flask-
bb58f851a52e

https://dev.to/farisdurrani/connecting-oracledb-with-nodejs-on-oracle-linux-8-1phm

https://www.digitalocean.com/community/tutorials/how-to-create-your-first-web-application-
using-flask-and-python-3

Install the NGINX Web Server and Proxy on Oracle Linux


https://docs.oracle.com/en/learn/ol-nginx/#introduction

How to Install Node.js and NPM on Oracle Linux


https://www.atlantic.net/dedicated-server-hosting/how-to-install-node-js-and-npm-on-oracle-linux/

You might also like