DPI-1047: 64-bit Oracle Client library cannot be loaded - python

I am trying to run oracle database in python.
Specifications:
1. Windows 7 64 bit
2. Python 32 bit 3.6 (Running on Jupyter(Anaconda Navigator)
3.Visual studio 2010 training kit module
4.Oracle instant client basic 12.2 32 bit
5.Oracle instant client basic SQL*Plus 12.2 32 bit
I have installed cx_Oracle via command
import sys
!conda install --yes --prefix {sys.prefix} cx_Oracle
import cx_Oracle
After that I have installed Oracle instant client basic 12.2 32 bit and Oracle instant client basic SQLPlus 12.2 32 bit in the same working directory from where Jupyter is connected.
I have copied both installed Oracle instant client basic and instant client basic SQLPlus in same folder and have given environment path of the same folder.
But whenever I am running the command it's giving error:
DPI-1047: 64-bit Oracle Client library cannot be loaded: "C:\oracle\product\10.2.0\client_1\bin\oci.dll is not the correct architecture". See https://oracle.github.io/odpi/doc/installation.html#windows for help
Although there is nothing of 64 bit except windows which I have search doesn't matter.

You need to install 64-bit Instant Client not 32-bit - the error is clear about this. When you run Python make sure Instant Client is in your PATH environment variable before the Oracle 10.2 directory, or any other Oracle libraries.

Related

cx_Oracle.DatabaseError: DPI-1047

I am trying to run a code to create tables in oracle database.I am using Python 3.6.5 and Oracle Database 10g Express Edition Release 10.2.0.1.0 in windows 64 bit.
con=cx_Oracle.connect(config.connection)
cx_Oracle.DatabaseError: DPI-1047: 64-bit Oracle Client library cannot be loaded: "C:\oraclexe\app\oracle\product\10.2.0\server\bin\oci.dll is not the correct architecture".
Seems like you are unable to connect to the Oracle DB. As pointed out here:
You need to install cx_Oracle extension for python and make sure environment variables are correctly set
In addition, see that the credentials in config.connection are correct.
Update: the latest major release of the cx_Oracle driver doesn't need Oracle libraries by default, so configuration is easier. The driver got renamed to python-oracledb, see the release announcement.
cx_Oracle 6+ needs to be using Oracle 11.2+ libraries. It seems you are linking it with your 10g DB libraries. You can install 11.2 libraries using the free Oracle Instant Client, set PATH to include them, and then connect to your 10g database - but don't stuff up PATH for other applications that need the 10g libraries. You'll probably need to use something like a BAT script to set PATH and then call python.
The Oracle 11.2 libraries must be the same 32-bit or 64-bit as Python is.
If there's anything unclear in https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html then log an issue on the cx_Oracle project at https://github.com/oracle/python-cx_Oracle/issues

Connecting Python 3.x to Oracle DB

I am unable to connect to our enterprise Oracle Db using python 3/cx_Oracle.
Installed are:
python 3 -32 bit
cx_Oracle
Oracle Client 12.1.0.2.0
My connection string attempt is:
import cx_Oracle
conn = cx_Oracle.connect(user='user', password='pwd', dsn='working_dsn')
My PATH variable includes the direct path to my working Oracle library (works using SQL Dev
Error message is:
cx_Oracle.DatabaseError: DPI-1050: Oracle Client library is at version 0.0 but must be at version 11.2 or higher
I have researched the Orcale installation instructions and have found no way to connect. I have previously tried with no success, had my computer reimaged and Oracle reinstalled to ensure only one version of Oracle and still no success. I need to move from R to Python and this is the last piece I need to make the switch. I am able to connect with R using JDBC driverclass/dbConnect.
If cx_Oracle wont work, is there another option for connecting to Oracle from Python3?
Any thoughts suggestions or places to look? Other connection types used?
Thanks in advance.
pip3 install cx_Oracle
first method:
db = cx_Oracle.connect('root/root#localhost: 1523/orcl')
Second method:
db = cx_Oracle.connect('root/root#localhost: 1523/orcl')
Third method
makedsn(IP/HOST, PORT, TNSNAME)
dsn = cx_Oracle.makedsn('localhost','1523','orcl')
db = cx_Oracle.connect('root','root',dsn)
The error you are getting suggests that you have an older version of the Oracle client installed on your machine. Search the directories of your PATH environment variable for OCI.DLL. If you find an older version you'll need to remove or rename it -- just be aware that whatever application put the file there will stop working!
Another possibility is to go to a command prompt and do the following
PATH=my_path_to_instant_client;%PATH%
python test_connect.py
Finally, make sure that if your Python is 32-bit, so is your instant client installation, and if your Python is 64-bit, make sure that your instant client installation is also 64-bit.

Import error while calling from IIS hosted .NET Core API

I am facing the below issue while running a python script from a .NET Core api which is hosted in windows server IIS .I am using pyrfc 1.9.5 SAP connector in this script. Here is the code below
from pyrfc import Connection
def GetConnection(connmeta):
return Connection(**connmeta)
Here is the error which I got -
from pyrfc import Connection
File "<C:\Program Files\Python35\lib\site-packages\pyrfc-1.9.5-py3.5-win-amd64.egg\pyrfc_init_.py>", line 22, in
from pyrfc._pyrfc import get_nwrfclib_version, Connection, TypeDescription, FunctionDescription, Server
ImportError: DLL load failed: The specified module could not be found
It's working fine from the command prompt, python IDLE, Powershell etc. Previously I got this error when the visual c++ redistributable package was not installed. But now it is installed properly as the same script is working from IDLE and Powershell.
Here are the installed software and server details -
windows server 2016 64 bit
Visual C++ 2013 redistributable 64 bit
Python 3.5 64 bit,
pyrfc 1.9.5 for python 3.5 64 bit (amd64)
SAP NW RFC SDK 7.5.0 64 bit
Python executable and the path to the lib folder of the SDK is already added to the Environment variable. I have also tried to execute the sample rfcexec.exe program from the bin directory it's working fine. I am only getting the error while running the application from IIS. The app pool identity has full permission on the python scripts.
The script is working fine from IIS if I comment the pyrfc import part.
Please help .
Finally I have found the solution after debugging for atleast 1 week. The problem was access related issue. the SAP NW RFC SDK was installed in the path C:\nwrfcsdk\lib as per the documentation.
link : Installation documentation
But the user account under which the .NET Core API was running in the application pool of IIS didn't have any read/write access to this nwrfcsdk folder. Hence pyrfc was not able to import the DLL (SAPNWRFC.dll) when the python script was being called from the .NET Core API.I have provided read/write access to that particular account and the script is running fine now .
I have followed the below steps to debug the diagnose the issue -
I have used profiling with Procmon.exe from sysinternals to monitor w3wp.exe IIS worker process and python.exe after calling the API
I have also used dependency walker to track the dependent dll.
Hope this helps someone who is facing a similar type of issue.

When using cx_Oracle does Oracle need to be installed on all computers with the python application?

I created an exe of my program that communicates with an oracle database using cx_Oracle to create excel sheets. If someone else uses this exe will they need Oracle installed?
Any computer that runs Python programs using cx_Oracle will need an 'Oracle client' installed. This is the set of Oracle libraries needed by cx_Oracle that allow connections to a database. The database can be on a remote computer. The Oracle client libraries are available in three different installs:
With the Oracle Database install
With a 'full' Oracle Client install
From Oracle Instant Client
The most common in your case would be to use Oracle Instant Client, which is relatively small and is simple to install.
You download the Instant Client 'Basic' package matching your operating system and the Python architecture (32 or 64 bit). Unzip it. Set your operating system search path such as PATH (on Windows) or LD_LIBRARY_PATH or ldconfig (on Linux) to the directory you unzipped.
Instant Client Downloads and instructions are at https://www.oracle.com/database/technologies/instant-client.html
cx_Oracle installation instructions are at https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html

Running a Python Script in 32 Bit on 64 linux machine to connect to oracle DB with 32 bit client

I am trying to set up a cronjob that executes a python (3.6) script every day at a given time that connects to an oracle 12g database with a 32 bit client (utilizing the cx_Oracle and sqlalchemy libs). The code itself was developed on a win64 bit machine.
However, when trying to deploy the script onto an Ubuntu 16.04 server, I run into a dilemma when it comes to 32 vs 64 bit architectures.
The server is based on a 64 bit architecture
The oracle db is accessible via a 32 bit client
my current python version on ubuntu is based on 64 bit and I spent about an hour of how to get a 32 bit version running on a 64 bit linux machine without much success.
The error I receive at this moment when trying to run the python script refers to the absence of an oracle client (DPI-1047). However, I already encountered a similar problem in windows when it was necessary to switch the python version to the 32 bit version and to install a 32 bit oracle client.
Is this also necessary in the ubuntu case or are there similar measurements needed to be taken? and if so, how do I get ubuntu to install and run python3.6 in 32 bit as well as the oracle client in 32 bit?
I am a bit confused about your question but this should give some clarification:
A 32-bit client can connect to a 64-bit Oracle database server - and vice versa
You can install and run 32-bit applications on a 64-bit machine - this is at least valid for Windows, I don't know how it works on Linux.
Your application (the python in your case) must have the same "bitness" as installed Oracle Client.

Categories