So I found Help installing cx_Oracle but am still stuck. I downloaded the latest instantclient from oracle, and set ORACLE_HOME to the location of the extracted files (both direct and with a bin folder between the ORACLE_HOME value and the files), but easy_install is popping an error when running setup.py saying it can't locate the Oracle include files. I did notice that only the 11g dll is in the folder, do I need all 3 drivers present for setup to complete? If so, where do I even get them?
You can check if you have the cx_Oracle package installed by running the pip show cx_Oracle command. Copied! The pip show cx_Oracle command will either state that the package is not installed or show a bunch of information about the package, including the location where the package is installed.
cx_Oracle requires Oracle Client libraries. The libraries provide the necessary network connectivity to access an Oracle Database instance. They also provide basic and advanced connection management and data features to cx_Oracle.
cx_Oracle is a Python extension module that enables access to Oracle Database. It conforms to the Python database API 2.0 specification with a considerable number of additions and a couple of exclusions. cx_Oracle 8.3 was tested with Python versions 3.6 through 3.10.
Go to the Oracle Database Instant Client website. In the Get Oracle Instant Client section, select Downloads. On the Oracle Instant Client Downloads page, select Instant Client for Microsoft Windows (x64). Choose Instant Client Package - Basic for your version of Oracle Database.
Honestly it is a hell of a lot easier to install cx_Oracle from one of the binary installers they have, than from source.
Browse to Instant Client for Linux x86 download page.
Download the latest version of basic, sqlplus and sdk packages that fit your architecture (32 or 64bits):
oracle-instantclient<version>-basic-<version_full>.<arch>.rpm
oracle-instantclient<version>-sqlplus-<version_full>.<arch>.rpm
oracle-instantclient<version>-devel-<version_full>.<arch>.rpm
.Install the RPMs using alien. For example, at the time of this writing:
$ sudo alien -i oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm
Add necessary environment variables (I personally did put it in /etc/environment
then logoff/back in to reload the env):
ORACLE_HOME=/usr/lib/oracle/<version>/client64/lib/
LD_LIBRARY_PATH=/usr/lib/oracle/<version>/client64/lib/
Fix oracle's includes:
$ sudo ln -s /usr/include/oracle/<version>/client $ORACLE_HOME/include # for 32bits arch, OR
$ sudo ln -s /usr/include/oracle/<version>/client64 $ORACLE_HOME/include # for 64bits arch
Create /etc/ld.so.conf.d/oracle-instantclient<version>-basic.conf
and /etc/ld.so.conf.d/oracle.conf
(for more recent versions, at least since 12.1) containing:
/lib
/usr/lib/oracle/<version>/client/lib ; for 32bits arch, OR
/usr/lib/oracle/<version>/client64/lib ; for 64bits arch
Reload ldconfig cache (use -v
flag if you want some verbose):
$ sudo ldconfig
You might need to install libaio1
.
Assuming we have installed Oracle Instant Client 10, you have different alternatives to install cx_Oracle:
$ pip install cx_oracle
(linux only)Older versions (version less than 5.1.2 are .msi and .rpm files) can be downloaded from here. Install the RPMs using alien. For example, at the time of this writing:
$ sudo alien -i cx_Oracle-5.0-10g-py25-1.x86.rpm
To test, python -c 'import cx_Oracle; print cx_Oracle'
should return the modules with its version.
step 1 check python is 32 bit or 64
import platform
platform.architecture()[0]#'32bit'
or step 2 install oracle client (32 bit or 64 bit depends on python version from step1)
the directory will appear like this
click on install and set the path to 'base' and 'software' directories
in this case 'installed' directory is base and 'software' directory is for software path
set ORACLE_HOME path:
set the oracle home path to the 'software' directory as 'F:\softwares\oracle11g32\installed\software'
step 3 install vcforpython27 or visual c++ 2008 express edition for python 2.7
download it from here https://www.microsoft.com/en-sa/download/details.aspx?id=44266 (used this in this case to avoid installation of whole visual c++ 2008 as mentioned in below)
it is a small package that contains c++ compilers for python 2.7
(Or)
visual c++ 2008 express edition ( https://www.microsoft.com/en-sa/download/details.aspx?id=5582 ) [it will around a 1 GB installation]
vcforpython27 will installed at 'C:\Users\Administrator\AppData\Local\Programs\Common\Microsoft'
enable show hidden folder in windows to this these directories
it should point to the point to the directory containing 'vcvarsall' batch file
echo %VS100COMNTOOL% to see if is pointing to the right directory in cmd
And do the steps below:(from:error: Unable to find vcvarsall.bat )
go to C:/Python27/lib/distutils the file msvc9compiler.py. Find in it the function find_vcvarsall and do following modification. Replace the line: productdir = os.path.join(toolsdir, os.pardir, os.pardir, "VC") with productdir = os.path.join(toolsdir) This is where vcvarsall.bat resides in this case (check, where vcvarsall.bat is in your installation).
install cx_Oracle
the easy step: pip install cx_oracle
if all the above steps are followed properly, then it should work. It took lot of pain to figure this out. I hope it will be useful.
recommended to run:
pip install --upgrade setuptools
from : https://stackoverflow.com/questions/2667069/cannot-find-vcvarsall-bat-when-running-a-python-script
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With