How to Install Oracle Instant Client on Apple Silicon M1

Vipavee M
Ascend Developers
Published in
3 min readSep 24, 2021

--

As Apple has released the M1 chip with a different architecture than the previous generation, it resulted in various apps including Oracle Instant Client not being able to work normally on Apple silicon. However, there’s Rosetta 2 — “A translation process that allows users to run apps that contain x86–64 instructions on Apple silicon” says by Apple. So, In this article I’m going to share my sample steps for setting up Oracle Database Instant Client in Apple Silicon M1.

If you are facing an issue related to installation of Oracle Database Instant Client on M1 something like “DPI-1047: Cannot locate a 64-bit Oracle Client library: mach-o, but wrong architecture”, you may consider the following solution as an alternative way to install Oracle Instant Client.

Steps to Install Oracle Instant Client on Apple Silicon

Step 1: install rosetta2

Use below command to install rosetta2:

/usr/sbin/softwareupdate — install-rosetta

Note: The above command will launch the Rosetta installer. Then, you just need to agree to its license agreement. However, you can skip the license agreement by providing this additional flag as below:

/usr/sbin/softwareupdate –install-rosetta –agree-to-license

Then, I duplicate the terminal and set default to “open using rosetta” and will use this terminal to install other items in the next steps.

Step 2: install brew

Use below command to install brew:

arch -x86_64 /bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Note: ensure that the library should located at (/usr/local/Homebrew/bin/brew)

Step 3: install python

Use below command to install python:

arch -x86_64 brew install python

Step 4: install pip and dependencies library

Use below command to install pip:

Note: make sure that the libraries are installed with -x86_64.

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

python get-pip.py

Step 5: download instant client

Link: https://www.oracle.com/database/technologies/instant-client/macos-intel-x86-downloads.html

> Move ${instantclient_folder_name} folder (group Basic Package, SQL*Plus Package, SDK Package as 1 folder) after unzip to /Users/[your user path]

> Create a folder ~/lib

> Create a symbolic link

- ln -s /Users/[your user path]/${instantclient_folder_name}/libclntsh.dylib ~/lib/

step 6: setup export path in .zshrc file

> sudo vi .zshrc

> Enter your mac password

> To insert text to file press -> i

Insert below paths to the file:

export PATH=/Users/[your user path]/instantclient:$PATH

export ORACLE_HOME=/Users/[your user path]/instantclient

export DYLD_LIBRARY_PATH=/Users/[your user path]/instantclient

export OCI_LIB_DIR=/Users/[your user path]/instantclient

export OCI_INC_DIR=/Users/[your user path]/instantclient/sdk/include

> Save and quit by command -> :wq

> source .zshrc

Step 7: Install cx_Oracle from PyPi

> python -m pip install cx_Oracle — upgrade — user

Note: The — user is optional and may be useful, if you don’t have permission to write to system directories

Step 8: try running SQLPlus

References:

https://stackoverflow.com/questions/64963370/error-cannot-install-in-homebrew-on-arm-processor-in-intel-default-prefix-usr

https://docs.brew.sh/Installation

--

--