cx_Oracle python module installation in Linux - python

I want to connect to Oracle database from Python script. For that, I am I am trying to install cx_oracle Python module. Oracle is not installed on my Linux box.
While installing cx_oracle module, it throws error saying "cannot locate an Oracle software installation"
Is there any way to connect to Oracle DB from python without installing Oracle in Linux box.
-bash-4.1$ pip install cx_Oracle
DEPRECATION: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of pip will drop support for Python 2.6
Collecting cx_Oracle
/usr/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
SNIMissingWarning
/usr/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Using cached cx_Oracle-5.3.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-PUb2Gy/cx-Oracle/setup.py", line 174, in <module>
raise DistutilsSetupError("cannot locate an Oracle software " \
distutils.errors.DistutilsSetupError: cannot locate an Oracle software installation
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-PUb2Gy/cx-Oracle/
/usr/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning

I would definitely recommend upgrading your Python installation, if only to avoid security issues that come with unsupported software. You can download a new version from https://www.python.org/downloads. Depending on your OS there may be ways of installing alternative versions of Python.
Python 2.6 support is still possible, however. If you are using Oracle Linux 6 or RHEL 6 you can download an RPM from here.
If you need to build from source, the simplest solution is to use cx_Oracle 6 with pip using the following command:
pip install cx_Oracle --upgrade --pre
cx_Oracle 6 doesn't require an Oracle client installation to compile but cx_Oracle 5 and earlier do.
At run-time, an Oracle client is required for all versions of cx_Oracle. The simplest to install is the Oracle Instant Client which you can find here.

sqlplus_commando may be what you need indeed.
You can use this driver in your code just like so:
from sqlplus_commando import SqlplusCommando
sqlplus = SqlplusCommando(hostname='localhost', database='test',
username='test', password='test')
result = sqlplus.run_query("SELECT 42 AS response, 'This is a test' AS question FROM DUAL;")
print result

Related

How do I resume installing additional node.js tools successfully without starting a duplicate chocolatey installation?

I lost my internet connection while installing additional tools for node.js. using the automatic installation option. I'm new to programming and trying to set up an environment for JavaScript on VS Code. I rebooted my system and tried resuming the installation through the Install Additional Tools for Node.js cmd prompt, but it gives a warning that there is already an existing chocolatey installation detected and thus not continuing installation. Furthermore, 2 packages failed to be upgraded from the initial error when the connection was lost, but now it says one package failed yet still showing 0/2 packages were upgraded? I uninstalled node.js and reinstalled it but it hasn't solved the issue. Is visualstudio2019-workload-vctools the only thing missing? Of which I could maybe try installing it manually? Or are the files now corrupted and I have to start over since installation didn't complete?
I don't want to mess with chocolatey itself (by uninstalling) as I read that it can destroy your pc. If there are still a few more tools or packages to install and files not corrupted, how do I successfully and safely resume the installation of all necessary tools? Python 3.10 looks to be successfully installed.
This is the message on PowerShell and the screenshot is attached as well:
"WARNING: 'choco' was found at 'C:\ProgramData\chocolatey\bin\choco.exe'.
WARNING: An existing Chocolatey installation was detected. Installation will not continue.
For security reasons, this script will not overwrite existing installations.
Please use choco upgrade chocolatey to handle upgrades of Chocolatey itself.
Chocolatey v1.1.0
Upgrading the following packages:
python;visualstudio2019-workload-vctools
By upgrading, you accept licenses for the packages.
python v3.10.5 is the latest version available based on your source(s).
visualstudio2019-workload-vctools is not installed. Installing...
visualstudio2019-workload-vctools not installed. An error occurred during installation:
The remote server returned an error: (524).
visualstudio2019-workload-vctools package files upgrade failed with exit code 1. Performing other installation steps.
The upgrade of visualstudio2019-workload-vctools was NOT successful.
visualstudio2019-workload-vctools not installed. An error occurred during installation:
The remote server returned an error: (524).
Chocolatey upgraded 0/2 packages. 1 packages failed.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
Failures
visualstudio2019-workload-vctools (exited 1) - visualstudio2019-workload-vctools not installed. An error occurred during installation:
The remote server returned an error: (524).
Type ENTER to exit:"
PowerShell-chocolatey error
I am thinking the failure is due to the fact that I don't have visual studio 2019? It seems like everything else is fine. I'm setting up using VS Code. It doesn't seem like the issue had anything to do with me losing connection. I have attached a screenshot of the successful vs failed installations.
additional node.js tools

McAfee Endpoint security Alert "Insufficient system resources" using cx_Oracle in Python:

I am using Cx_oracle for a while in Python but I can not recently import cx_oracle in Python and got this error:
ImportError: DLL load failed: Insufficient system resources exist to complete the requested service.
In addition, I get McAfee security alert as shown below:
I reinstalled cx_oracle a few times and it has not worked. Any suggestions?
The easiest answer is to use an older version of cx_Oracle using the following commands:
pip uninstall cx_Oracle
pip install -Iv cx_Oracle=="enter the version number here"
The reason is that McAfee might not integrate with the latest version of cx_Oracle or any other Python modules.
There are several other solutions including:
Uninstalling McAfee or any antivirus software that you have
Updating the drivers
Scanning the disk drivers to solve the issue
Modify the registry

Python PIP and InsecurePlatformWarning

I'm trying to install requests library for Python (2.6.6 on CentOS6) as
sudo pip install requests[security]
I'm getting these error messages:
/usr/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Collecting requests[security]
/usr/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
/usr/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
I ensured all system libraries are in place
sudo yum install openssl-devel python-devel libffi-devel
and all is good there
so I tried
sudo pip install pyopenssl ndg-httpsclient pyasn1
and
sudo pip install --trusted-host pypi.python.org requests
and these fail as well.
Due to some old code I need to stick to Python 2.6
Any idea what is going wrong here and how to address it?
PS
I have decided to downgrade pip and it came up that errors came up with pip version 6.1+. Thoughts on that?
Indeed, as of 2019, quite a few people are still facing this issue, as they cannot upgrade their system Python (and system-supplied openssl) due to various limitations.
If you'd like to fix the InsecurePlatformWarning .. (Caused by SSLError .. SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version'), the following solution can help someone using an old Linux distro:
Unable to install Python packages using pip in Ubuntu Linux: InsecurePlatformWarning, SSLError, tlsv1 alert protocol version
Python 2.6.6 on CentOS6
In your specific case, the last cryptography version to officially support Python 2.6 was cryptography-2.1.1, although a newer version might work.
The first manylinux1 cryptography package to include its own OpenSSL (1.1.0f) shared lib binding for Linux, regardless of what's on your platform, has appeared in cryptography-2.0 version. The last cryptography that still officially supported Centos 6.4 was version 1.8.2, while newer versions officially supported CentOS 7.x only: https://pypi.org/project/cryptography/#files
Note, cryptography versions<2.0 have no manylinux1 and didn't ship the openssl/ssllib with them, relying on the system-supplied one only (back then, they did so only for other OSes that had/have even bigger SSL problems). While the cryptography-2.0 (manylinux1) is still worth trying, you will probably have to compile the newer openssl version (1.0.1 - 1.1.0) locally on Centos 6.x, before compiling cryptography 1.8.2 to link against it:
https://cryptography.io/en/latest/installation/#using-your-own-openssl-on-linux
https://cryptography.io/en/latest/installation/#rhel-centos
There is also an option to build your own statically-linked wheels that will work on your own systems:
https://cryptography.io/en/latest/installation/#static-wheels
That said,
if all you needed was just to install the requests lib (without solving the notorious SSLError), specifically in Python 2.6.6 on CentOS6, and you are not going to need TLS 1.2 protocol support from requests, you could simply use your Centos repo for that:
$ yum search requests
$ sudo yum install python26-requests
Or, you could get and install requests in a similar way as in the above-mentioned solution, from wheels or from tar.gz downloaded from:
https://pypi.org/project/requests/
Note, the latest requests on PyPI depends on the following Python packages:
urllib3, idna, chardet, certifi
Luckily, these four have no other dependencies and can be obtained from PyPI directly, in the same way - the "Download Files" section on PyPI:
https://pypi.org/project/urllib3/
https://pypi.org/project/idna/
https://pypi.org/project/chardet/
https://pypi.org/project/certifi/
You could download and try to install their latest versions, or use 'Release History' section to locate older versions, depending on your use-case and system-specific requirements.
Note, many web servers (including PyPI) nowadays require TLS 1.2 support, both in the client and server backend, to establish an HTTPS connection, so if you will need this type of connections, requests will not work without fixing the SSLError the way discussed above (or by compiling a newer Python 2.7.9+ against OpenSSL version 1.0.2+ that would have to be compiled as well in that case, before compiling new Python, to link ssl module with it).
Try this:
sudo pip install requests
[secure] is not necessary

Cannot install dlib on mac os X

I am following the instructions here: http://www.pyimagesearch.com/2017/03/27/how-to-install-dlib/
line by line, except for the line where python3 is installed. I made a virtual environment and inside the virtualenv, did these four lines:
$ pip install numpy
$ pip install scipy
$ pip install scikit-image
$ pip install dlib
Unlike the instructions, the last line took a few seconds, not 15 minutes. After the installation, I opened ipython and tried import dlib, and receive this message:
----> 1 from .dlib import *
2 __version__ = "19.4.0"
ImportError: dlopen(/Users/myname/Documents/camera-project/code/story-board/cv/lib/python2.7/site-packages/dlib/dlib.so, 2): Library not loaded: #rpath/libmkl_rt.dylib
Referenced from: /Users/myname/Documents/camera-project/code/story-board/cv/lib/python2.7/site-packages/dlib/dlib.so
Reason: image not found
I assume this means dlib is not properly installed, but I am not sure what I did wrong?
Also, I should add that I do not haveanaconda on my mac, so it cannot be the issue. However earlier today I did, and I could load dlib without an issue, presumably because I am running a version of python distributed by anaconda, and I assume dlib comes with anaconda. However the X11 distributed by anaconda is broken so I had to remove anaconda completely from my system and start over.
EDIT
This is the message I get after installing dlib "successfully":
:/Library/Python/2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
SNIMissingWarning
/Library/Python/2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Installing collected packages: dlib
Successfully installed dlib-19.4.0
You may need to install the pakage cmake.
When I tried installing dlib on my Mac in a virtualenv just now, I got the error
running bdist_wheel
running build
error: Cannot find cmake, ensure it is installed and in the path.
You can install cmake on OSX using `sudo brew install cmake`.
You can also specify its path with --cmake parameter.
So I would recommend trying to install cmake with
brew install cmake

python setup.py fails on osx with ssl error

I am trying to upload a new python project from my mac to PyPI via:
python setup.py sdist upload -r pypi
When I try to upload a package, I get the following error on OSX:
Submitting dist/PyTreasuryDirect-0.1.0.tar.gz to https://pypi.python.org/pypi
error: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)>
This question is slightly related to these two questions, ssl with pip and when importing the ssl library. However I need setup.py to work in my case, how can I get past this ssl error?
I also get the same error on Python 2.7.9 and Python 3.5 using OSX 10.10.2 (14C109)
The solution for OS X 10.10 is to use its default Python version 2.7.6.
This problem is related to the fact that starting from Python version 2.7.9 certificate validation for stdlib http clients is enabled by default (PEP 476). This issue is described in Python bug tracker.

Categories