MOD_WSGI cannot locate Oracle instantclient library - python

I have a flask app running on Apache server using mod_wsgi. Everything works fine until I try to access the database using cx_Oracle. At that moment I get the following error:
sqlalchemy.exc.DatabaseError: (cx_Oracle.DatabaseError) DPI-1047: Cannot locate a 64-bit Oracle Client library: "The specified module could not be found". See https://oracle.github.io/odpi/doc/installation.html#windows for help.
I have added the client library path to the os environment variables.
It works well if I start the application from Pycharm IDE.
I have even added the following line in my .wsgi file.
sys.path.append('D:\FlaskDev\instantclient_11_2')
Can anyone help? Thanks in advance

If your python is 64Bits you must to use an 64 instant client too.
Try to follow this instructions.

Related

mysql.connector.errors.NotSupportedError: Authentication plugin 'mysql_native_password' is not supported only with pyinstaller exe

I am fighting to find a solution for my problem:
When I start my Python application in my IDE, the database connection is working fine. But when I build an exe with pyinstaller with the following command python3 -m PyInstaller .\home.py and start the application and trigger the connection to the db it gives me the following error:
Previously I had the same error with "caching_sha2_password" instead of "mysql_native_password", then I changed the db plugin to "mysql_native_password" but it still doesn't work in the exe.
My database is running in a Docker Container. The root user, which I use for the connection has also mysql_native_password as the authentication plugin.
However, somehow the connection to the db works every time when I start my application from my IDE. This problem only occurs, after I have exported my application into an exe with pyinstaller.
The connection to the db looks like this:
mysql.connector.connect(
host="localhost",
user="user",
passwd="password",
database="db_name"
)
And yes, I have already checked, that I only have mysql-connector-python installed.
I would be very glad if you could help me out, as this is the final step of my application to be ready for shipment.
Thank you in advance!
After a lot of stress, I decided to install an older version of mysql-connector-python from this site https://downloads.mysql.com/archives/c-python/
I installed the 8.0.20 and for now, working.
test later and verify.
I had this same bug for weeks.
The only difference with you is that I didn't use pyinstaller, but the CX_Freeze.
After I could not find an answer for my problem, I just switched to Postgres and used the corresponding Python driver. Now it works!
When the .exe file is created "caching_sha2_password" is not found...you have to turn debug mode on when creating the .exe file, then you will see the error message.
So the way to resolve the issue is to import "caching_sha2_password" explicitly in your python script, like so:
from mysql.connector.plugins import caching_sha2_password

"libnnz19.so: cannot open shared object file: No such file or directory

I have installed cx_oracle(python3) and instant client 21_1 inside a container. When I try to first time I got this error
Cannot locate a 64-bit Oracle Client library: "/python-
env/instantclient_21_1/lib/libclntsh.so:
So I have created lib under /python-env/instantclient_21_1/ and tried again, now I'm getting this error
cx_Oracle.DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: "libnnz19.so: cannot open shared object file: No such file or directory". See https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html for help
I don't understand where is it searching for the that so file. It is already present in /python-
env/instantclient_21_1/lib/
Please help
Follow the Instant Client installation steps or cx_Oracle Installation steps and use ldconfig to set the library path to include the Instant Client directory.
You could set DPI_DEBUG_LEVEL=64 (see here) to trace how cx_Oracle is looking for the libraries.
Also see Docker for Oracle Database Applications in Node.js and Python.

DPI-1047 error on connecting to Oracle Database in Django

i am trying to connect my oracle 11g database to django but it didn't connect it show some error like
return Database.connect(
django.db.utils.DatabaseError: DPI-1047: Cannot locate a 32-bit Oracle Client library: "C:\oraclexe\app\oracle\product\11.2.0\server\bin\oci.dll is not the correct architecture". See https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html for help
i sucessfully install 32 bit oracle client library but it still shows same error.
i am new to django and this error pops up when i use command python manage.py makemigrations it didn't create migration instead it shows this error.
it would be pleasure if someone helps me.
thankyou :)
The error is because you have a 64-bit Oracle Database installed, and its libraries are first in PATH so Python cx_Oracle tries to load them. Unfortunately your Python is 32-bit so there is a clash, which is shown by the error.
You choices are to set PATH to have your 32-bit Oracle client libraries first when you run Python. You probably don't want to do this globally since that might affect other Oracle DB tools, so you would need to do it in a cmd terminal, or set up a script that sets PATH and then calls python. You would call your new script anytime you wanted to run Python.
Overall, it's probably easier to uninstall Python, and install a 64-bit Python.

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.

cx_oracle and oracle 7?

At work we have Oracle 7. I would like to use python to access the DB.
Has anyone done that or knows how to do it?
I have Windows XP, Python 2.6 and the cx_oracle version for python 2.6
However, when I try to import cx_oracle i get the following error:
ImportError: DLL load failed the module could not be found
Any help is appreciated!
Matt
cx_Oracle is currently only being provided with linkage to the 9i, 10g, and 11i clients. Install one of these clients and configure it to connect to the Oracle 7 database using the proper ORACLE_SID.
Make sure you have the location of the oracle .dll (o files set in your PATH environment variable. The location containing oci.dll should suffice.
I was running into that same problem at work. I finally dropped trying to use cx_Oracle and went with adodbapi. It worked with Oracle 8.
If you have ODBC configured then you can use it. It is available with ActivePython or as win32 extensions. You will obtain connection with:
connection = odbc.odbc('db_alias/user/passwd')
Optionally you can use Jython and thin JDBC client. Instalation of client is not required. With Jython you have access to db via db url:
db = DriverManager.getConnection(db_url, usr, passwd)
where db_url looks like:
jdbc:oracle:thin:user/passwd#machine_ip:port:dbname

Categories