Installing python on oracle linux

Installing python on oracle linux

Instructions for installing Python for Linux for an on-premises Oracle database.

Python 3.9.5 required to install and use OML4Py .

These steps describe building and installing Python 3.9.5 for Linux.

    Go to the Python website and download the Gzipped source tarball . The downloaded file name is Python- 3.9.5 .tgz

wget https://www.python.org/ftp/python/3.9.5/Python-3.9.5.tgz
mkdir -p $ORACLE_HOME/python tar -xvzf Python-3.9.5.tgz --strip-components=1 -C $ORACLE_HOME/python
rpm -qa perl-Env rpm -qa libffi-devel rpm -qa openssl rpm -qa openssl-devel rpm -qa tk-devel rpm -qa xz-devel rpm -qa zlib-devel rpm -qa bzip2-devel rpm -qa readline-devel rpm -qa libuuid-devel rpm -qa ncurses-devel

If the libraries are present, then those commands should return messages such as the following. Depending on the version of Linux that you are using, such as version 7.3 or 7.5, the exact messages differ slightly.

perl-Env-1.04-2.el7.noarch libffi-devel-3.0.13-19.el7.i686 libffi-devel-3.0.13-19.el7.x86_64 openssl-devel-1.0.2k-19.0.1.el7.x86_64 tk-devel-8.5.13-6.el7.i686 xz-devel-5.2.2-1.el7.x86_64 zlib-devel-1.2.7-17.el7.x86_64 zlib-devel-1.2.7-17.el7.i686 bzip2-devel-1.0.6-13.el7.x86_64 bzip2-devel-1.0.6-13.el7.i686 readline-devel-6.2-11.el7.i686 readline-devel-6.2-11.el7.x86_64 libuuid-devel-2.23.2-61.el7_7.1.x86_64 ncurses-devel-5.9-14.20130511.el7_4.x86_64

The actual value returned depends on the version of Linux that you are using. If no output is returned, then install the packages as sudo or root user.

sudo yum install perl-Env libffi-devel openssl openssl-devel tk-devel xz-devel zlib-devel bzip2-devel readline-devel libuuid-devel ncurses-devel
cd $ORACLE_HOME/python ./configure --enable-shared --prefix=$ORACLE_HOME/python make clean; make make altinstall

Note: Be sure to use the —enable-shared flag if you are going to use Embedded Python Execution; otherwise, using an Embedded Python Execution function results in an extproc error. Be sure to invoke make altinstall instead of make install to avoid overwriting the system Python.

export PYTHONHOME=$ORACLE_HOME/python export PATH=$PYTHONHOME/bin:$PATH export LD_LIBRARY_PATH=$PYTHONHOME/lib:$LD_LIBRARY_PATH

pip will return warnings during package installation if the latest version is not installed. You can upgrade the version of pip to avoid these warnings:

python3 -m pip install --upgrade pip
cd $ORACLE_HOME/python/bin ln -s python3.9 python3

You can now start Python by running the command python3 . To verify the directory where Python is installed, use the sys.executable command from the sys package. For example:

$ python3 Python 3.9.5 (default, Feb 22 2022, 15:13:36) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44.0.3)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> print(sys.executable) /u01/app/oracle/product/19.3/dbhome_1/python/bin/python3

This returns the absolute path of the Python executable binary.

Читайте также:  Linux samba share password

If you run the command python3 and you get the error command not found , then that means the system cannot find an executable named python3 in $PYTHONHOME/bin . A symlink is required for the OML4Py server installation components. So, in that case, you need to create a symbolic link in your PREFIX /bin directory to link to your python3.9 executable as described in Step 6.

Источник

How to install python3-dev in Oracle Linux?

How can I install python3-dev in Oracle Linux? yum install python3-dev is not working. It gives a message:

I need python3-dev to convert a python script to Linux executable using Cython. I tried to search rpm files, that also did not work.

4 Answers 4

friend, OL6 and OL7 repo havent python 3, only 2

OL7 official repo
OL6 official repo

wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tar.xz xz -d Python-3.6.5.tar.xz tar -xvf Python-3.6.5.tar cd Python-3.6.5 ./configure make make test sudo make install 

if no step goes wrong, take a coffe, wait about 10 minutes in make test phase and be happy.

The hard way is with the following statements:

Note I used oraclelinux:7-slim docker container

yum -y install wget \ && yum -y install gcc readline readline-devel \ && yum -y install zlib zlib-devel \ && yum -y install libffi-devel openssl-devel \ && yum -y install tar gzip \ && yum -y install make \ && yum clean all wget https://www.python.org/ftp/python/3.7.5/Python-3.7.5.tgz \ && tar -xf Python-3.7.5.tgz \ && cd Python-3.7.5 \ && ./configure --enable-optimizations \ && make \ && make test && make install 

And the easy way is:

yum update \ && yum -y install python3 

Источник

Installing python on oracle linux

This chapter describes how to install multiple versions of Python and switch between them on the same Oracle Linux system.

To install Python and prerequisites, use the dnf module install command. Multiple versions of Python can be installed and used simultaneously on the same machine, such as Python 2.7 and Python 3.6. You can specify which version you intend to use as follows:

The python command is not aliased by default in Oracle Linux 8. Specify the Python interpreter version with the python2 and python3 commands when you launch Python scripts.

If you need to alias the python command to fix compatibility problems with existing scripts and applications, you can set it manually. For example, to set Python 2 as the default interpreter version:

sudo alternatives --set python /usr/bin/python2

For more information about using the python command, see the python(1) manual page.

Читайте также:  Ошибка при установке alt linux

Python 3.6 is supported for the full lifespan of Oracle Linux 8.

Application Stream packages, such as Python 2.7 and more recent versions of Python 3, have their own major version releases and may have shorter support lifespans. For more information, see Appendix B in Oracle Linux: Managing Software on Oracle Linux.

Installing Python 2

To install Python 2.7 on your Oracle Linux 8 system:

sudo dnf module install python27

Python 2 is no longer maintained by the Python community. Oracle strongly recommends that you migrate your existing Python 2 scripts and applications to Python 3.

To learn about about the 2to3 automated migration tool visit https://docs.python.org/3/library/2to3.html. See also the porting guide at https://portingguide.readthedocs.io/en/latest/ for more in-depth information.

Installing Python 3

To install Python 3.6 on your Oracle Linux 8 system:

sudo dnf module install python36

If you are running Oracle Linux 8.2 or later, you can optionally also install Python 3.8:

sudo dnf module install python38

If you are running Oracle Linux 8.4 or later, you can optionally also install Python 3.9:

sudo dnf module install python39

All of those Python 3 modules can be installed and used simultaneously on the same machine, and you can specify which installation you intend to use as follows:

By default, the python3 command is always aliased to Python 3.6 if it is installed on the system, but you can change it manually. For example, to set Python 3.9 as the default interpreter for the python3 command:

sudo alternatives --set python3 /usr/bin/python3.9

Installing Additional Python Libraries

You can also install additional dependencies from the Oracle Linux yum server. For example, to install the requests library for Python 3, you would install the python3-requests package:

sudo dnf install python3-requests

Dependencies that are installed in this way are available for any compatible Python installations on the same system. In addition, any matching packages can also be safely removed without also removing existing Python installations.

Источник

How to Install Python on Oracle Linux

How to Install Python on Oracle Linux

Python is a popular, high-level, and versatile programming language that can be utilized for various purposes such as web development, data analysis, artificial intelligence, and more. If you’re using Oracle Linux, you might want to install Python to leverage its capabilities. In this tutorial, we’ll guide you through the process of how to install Python on Oracle Linux.

Читайте также:  Распознавание лиц видеонаблюдение linux

Table of Contents

  1. Prerequisites
  2. Installing Python using YUM
  3. Installing Python from Source
  4. Verify Python Installation
  5. Setting up a Virtual Environment
  6. Conclusion

Prerequisites

Before you begin, ensure that you have:

If you need help with other Oracle Linux installations, check out these guides:

How to Install Python on Oracle Linux

Installing Python using YUM

Oracle Linux uses YUM (Yellowdog Updater, Modified) as the package manager. To install Python using YUM, follow these steps:

sudo yum install epel-release

This command installs the latest available version of Python 3 from the EPEL repository.

Installing Python from Source

If you want to install a specific version of Python or prefer to compile it from source, follow these steps:

sudo yum groupinstall "Development Tools" sudo yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
wget https://www.python.org/ftp/python/3.x.y/Python-3.x.y.tar.xz

Replace 3.x.y with the desired version number, for example, 3.9.7 .

./configure --enable-optimizations
make sudo make altinstall

Using altinstall instead of install prevents the new Python installation from conflicting with the system’s default Python.

Verify Python Installation

To verify that Python is installed correctly, run the following command:

This command should output the installed Python version.

Setting up a Virtual Environment

Using a virtual environment is a best practice for Python development, as it allows you to isolate project dependencies. To set up a virtual environment, follow these steps:

sudo yum install python3-venv
mkdir my_project cd my_project

This command creates a new virtual environment named venv in the my_project directory.

After activating the virtual environment, your command prompt should change to indicate that the virtual environment is active.

Replace package_name with the desired package to install, for example, numpy or django .

Deactivating the virtual environment returns you to the system’s default Python environment.

Conclusion

You have successfully installed Python on your Oracle Linux system and set up a virtual environment for your Python projects. Python is a powerful language with many applications, and having it installed on your Oracle Linux system will enable you to develop a wide variety of projects.

For more Oracle Linux tutorials and guides, check out the following articles:

Источник

Оцените статью
Adblock
detector