cx_Oracle 5.1.1 under apache+mod_wsgi - python

if I use cx_Oracle 5.0.4, I can connect from python console, and works under apache+django+mod_wsgi
but when I update cx_Oracle 5.1.1, I can connect from python console, BUT same code doesn't work under apache+django+mod_wsgi
File "C:\Python27\lib\site-packages\django\db\backends\oracle\base.py", line 24, in
raise ImproperlyConfigured("Error loading cx_Oracle module: %s" % e)
TemplateSyntaxError: Caught ImproperlyConfigured while rendering: Error loading cx_Oracle module: DLL load failed: The specified module could not be found.
PS: python 2.7
PSS: I have instaled MSVC 2008 Redistributable x86

Need a solution as well.
I have the same setup on WinXP (Apache 2.2.21/ mod_wsgi 3.3/ python 2.7.2/ cx_Oracle 5.x.x). I found that cx_Oracle 5.1 also fails with the same error. Only 5.0.4 works.
Here is the list of changes that were made from 5.0.4 to 5.1:
Remove support for UNICODE mode and permit Unicode to be passed through in
everywhere a string may be passed in. This means that strings will be
passed through to Oracle using the value of the NLS_LANG environment
variable in Python 3.x as well. Doing this eliminated a bunch of problems
that were discovered by using UNICODE mode and also removed an unnecessary
restriction in Python 2.x that Unicode could not be used in connect strings
or SQL statements, for example.
Added support for creating an empty object variable via a named type, the
first step to adding full object support.
Added support for Python 3.2.
Account for lib64 used on x86_64 systems. Thanks to Alex Wood for supplying
the patch.
Clear up potential problems when calling cursor.close() ahead of the
cursor being freed by going out of scope.
Avoid compilation difficulties on AIX5 as OCIPing does not appear to be
available on that platform under Oracle 10g Release 2. Thanks to
Pierre-Yves Fontaniere for the patch.
Free temporary LOBs prior to each fetch in order to avoid leaking them.
Thanks to Uwe Hoffmann for the initial patch.

Related

ImportError when importing cx_Oracle with PyPy

I was previously using python to pass multiple queries to an Oracle Database but the script took too long to execute. So I decided to opt for PyPy and use the JIT Compiler rather than the CPython interpreter. I installed PyPy via apt and then compiled the script with the command:
pypy script_file.py
It returned back the following error:
import cx_Oracle
ImportError: No module named cx_Oracle
Is cx_Oracle not supported by PyPy or am I doing something incorrectly? If it is, is this due to an issue with the environment values and how can I set it right?
Thank you for the help! Sorry for the bad English.
Regardless of PyPy support, each connection to Oracle Database will still only ever be able to execute one statement at a time. You could stick with CPython and look at other architectures such as opening multiple connections. Also tune your queries and tune how cx_Oracle fetches data, eg. with arraysize and the (new in cx_Oracle 8) prefetchrows. See the cx_Oracle manual section Tuning cx_Oracle.

Oracle DPI-1047 on macOS 10.14.6 with Python 2.7.10

I am quite puzzled by the following situation: a colleague and I both use Mac OS X. I use 10.15.3, python 2.7.15, GCC 4.2.1, cx_Oracle 7.0.0 with the SQL Developer 19.1.0. She uses 10.14.6, python 2.7.10, GCC 4.2.1, cx_Oracle 7.3.0 with the SQL Developer 18.3.0.
We have a simple python script that connects to a data base via cx_Oracle. We got the usual DPI-1047 error. I followed the instructions here https://oracle.github.io/odpi/doc/installation.html#macos and with the latest 19 "Basic" version, and a bit of tweaking because of the notarization (https://github.com/oracle/python-cx_Oracle/issues/341#issuecomment-541794557) I could make it work: the .dylib files are properly picked up and the code can connect to the db.
For my colleague, the file cannot be found. We followed the exact same steps as for my computer, downloaded first the 19 then the 18 "Basic" version (naively thinking it would be related to the SQL Developer version), unzipped, and added the link to the $LD_LIBRARY_PATH variable. However, the DPI-1047 error remains to pop up.
We tried to follow previous solutions in this or other forums, but they wouldn't apply or work for us:
https://github.com/oracle/python-cx_Oracle/issues/210 (with https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html#ic_x64_inst) -> the same for us except the "per step 3" part does not apply -> we do not have any .so files in the instantclient download
DPI-1047: 64-bit Oracle Client library cannot be loaded - we verified that we both use 64-bit python using python -c 'import sys;print("%x" % sys.maxsize, sys.maxsize > 2**32)', rest in this thread applies to Windows
How to fix: cx_Oracle.DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library - Python - there is no /usr/lib/oracle folder, neither for me nor for her, where one would need to set the version explicitly; in fact, the downloaded folder contains a soft link to the proper version of the .dylib already (we also played around with having it point to other .dylib versions)
Thank you for your help!
c.
In summary you have an issue on the 10.14.6 (Mojave) computer.
My initial thought was that you are using the OS default Python. This won't work because Apple has locked it down. From the install instructions: "Make sure you are not using the bundled Python. This has restricted entitlements and will fail to load Oracle client libraries." (I have not/cannot venture into hacking Instant Client to see if it can be made to work)
However, where did Python 2.7.10 come from? My system default is Python 2.7.16.
Don't set LD_LIBRARY_PATH. Instead my ~/lib directory has just one symbolic link:
libclntsh.dylib -> /Users/cjones/instantclient_19_3/libclntsh.dylib
All the configuration issues are due to Apple's ever tightening security requirements. Hopefully the next Oracle Instant Client release will make it easier to use.
SQL Developer is almost completely unrelated to Python cx_Oracle usage (unless you use thick-JDBC connections in SQL Developer, which is rare).
And don't follow Linux or Windows instructions on macOS!

PostgreSQL FDW extension Multicorn - "Error in python: ImportError"

I'm trying to install Multicorn extension on PostgreSQL 9.3.3, but the problem I have that this extension only works with Python 2.7 or 3.3 whereas default version of python on my OS (Centos 6.5) is 2.6 and I can't change it without breaking the whole system.
I've installed python 2.7 alongside the default version and compiled Multicorn extension from source changing python references/paths in makefile to python 2.7, however I'm having trouble using the extension in Postgres.
Create extension command works just fine:
CREATE EXTENSION multicorn;
Creating the server, however fails:
CREATE SERVER csv_srv foreign data wrapper multicorn options (wrapper 'multicorn.csvfdw.CsvFdw');
ERROR: Error in python: ImportError
DETAIL: No module named multicorn
Is there a fix for this or at least a hint what to look for?
My assumption is that even though the extension itself was compiled with references to python 2.7 and all the files copied to the right folder /usr/local/lib/python2.7/dist-packages/multicorn-1.0.2-py2.7-linux-x86_64.egg/multicorn, PostgreSQL itself still uses the system default python 2.6 version and therefor fails to load the module. Is there any way to override python version that Postgres uses? Would that solve the problem?
You'll need to recompile PL/Python against Python 2.7.
Right now PL/Python will keep using Python 2.6. They aren't binary compatible and have separate sonames, libpython2.7.so and libpython2.6.so. So just changing the PATH and LD_LIBRARY_PATH will do nothing.
I would do this by downloading the PostgreSQL SRPM, modifying the spec file so it targets python 2.7, and rebuilding the RPMs.

Error when importing cx_Oracle module [Python]

I use Windows 7 64 bit and Oracle 10g. I have installed python-2.7.2.amd64 and cx_Oracle-5.1-10g.win-amd64-py2.7.
When I importing cx_Oracle module I get this error:
Traceback (most recent call last):
File "C:\Osebno\test.py", line 1, in
import cx_oracle
ImportError: No module named cx_oracle
Can someone please tell me what is wrong?
Have you tried import cx_Oracle (upper-case O) instead of import cx_oracle?
I had this same issue under Windows.
I used Dependency Walker to open up the cx_Oracle.pyd file in C:\Python\Libs\site-libraries\ and reviewed the findings that dependency walker gave.
Dependency Walker showed me that in this case I had the x86 version of Python 2.7.2 installed and x64 version of the Oracle client & client DLL (oci.dll) and was trying to use the x64 version of the cx_Oracle module. With that knowledge I installed Python 2.7.2 x86_64 for Windows and everything was right as rain.
The alternative was to install the x86 version of the Oracle client & cx_Oracle which is much more of a PITA than installing a new Python interpreter.
Also, as this was news to me, you must have the Oracle client installed as well as it provides the 'OCI.dll' client library that cx_Oracle uses. It's located here: Oracle Client Installer Windows x64. Probably helps if one reads the documentation. ;)
Either way, Dependency walker could give you a big clue as to what your issue is if you're having import errors. Unfortunately on-import error messages can be quite ambiguous. I received the same error you referenced and number of other less than specific errors as well.
after installing the cx_Oracle download the instant client form oracle owth all DLLs , then copy then in the same directory of cx_Oracle.pyd , it will work directly
tried and worked for me.
It's not finding the module.
Things to investigate: Do you have several python installations? Did it go to the right one? Do a global search for cx_oracle and see if it's in the correct place. Check your PYTHONPATH variable. Check Python's registry values HKLM\Software\Python\Pyhoncore. Are they correct?
See this answer: https://stackoverflow.com/a/19552263/496289
ignore this.... making up other 17 bytes that're needed to make this post long enough...

Why Python informixdb package is throwing an error!

I have downloaded & installed the latest Python InformixDB package, but when I try to import it from the shell, I am getting the following error in the form of a Windows dialog box!
"A procedure entry point sqli_describe_input_stmt could not be located in the dynamic link isqlit09a.dll"
Any ideas what's happening?
Platform: Windows Vista (Biz Edition), Python 2.5.
Which version of IBM Informix Connect (I-Connect) or IBM Informix ClientSDK (CSDK) are you using? The 'describe input' function is a more recent addition, but it is likely that you have it.
Have you been able to connect to any Informix DBMS from the command shell? If not, then the suspicion must be that you don't have the correct environment. You would probably need to specify $INFORMIXDIR (or %INFORMIXDIR% - I'm going to omit '$' and '%' sigils from here on); you would need to set INFORMIXSERVER to connect successfully; you would need to have the correct directory (probably INFORMIXDIR/bin on Windows; on Unix, it would be INFORMIXDIR/lib and INFORMIXDIR/lib/esql or INFORMIXDIR/lib/odbc) on your PATH.
Does other way to connect to database work?
Can you use (configure in control panel) ODBC? If ODBC works then you can use Python win32 extensions (ActiveState distribution comes with it) and there is ODBC support. You can also use Jython which can work with ODBC via JDBC-ODBC bridge or with Informix JDBC driver.

Categories

Resources