GVKun编程网logo

Windows上的easy_install cx_Oracle(Python软件包)(easy-install.pth)

9

对于Windows上的easy_installcx_Oracle感兴趣的读者,本文将提供您所需要的所有信息,我们将详细讲解Python软件包,并且为您提供关于BuildandInstallcx_Ora

对于Windows上的easy_install cx_Oracle感兴趣的读者,本文将提供您所需要的所有信息,我们将详细讲解Python软件包,并且为您提供关于Build and Install cx_Oracle on Mac Leopard Intel、CentOS安装python的easy_install、cx_Oracle - Python Interface for Oracle Database、easy_install cx_Oracle(python包)在Windows上的宝贵知识。

本文目录一览:

Windows上的easy_install cx_Oracle(Python软件包)(easy-install.pth)

Windows上的easy_install cx_Oracle(Python软件包)(easy-install.pth)

因此,我找到了安装cx_Oracle的帮助,但仍然无法解决。我从oracle下载了最新的即时客户端,并将ORACLE_HOME设置为提取文件的位置(直接使用,并在ORACLE_HOME值和文件之间使用bin文件夹),但是easy_install在运行setup.py时弹出错误,说可以。
t找到Oracle包含文件。我确实注意到文件夹中只有11g dll,我是否需要所有3个驱动程序才能完成安装?如果是这样,我什至可以从哪里得到它们?

答案1

小编典典

坦白说,要从他们的二进制安装程序之一安装cx_Oracle比从源代码安装要容易得多。

* nix的方法:

  1. 浏览到适用于Linux x86的Instant Client下载页面。

  2. 下载适合您的体系结构(32位或64位)的最新版本的基本,sqlplus和sdk软件包:

    • oracle-instantclient<version>-basic-<version_full>.<arch>.rpm
    • oracle-instantclient<version>-sqlplus-<version_full>.<arch>.rpm
    • oracle-instantclient<version>-devel-<version_full>.<arch>.rpm
    • 使用Alien安装RPM。例如,在撰写本文时:

      $ sudo alien -i oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm

  3. 添加必要的环境变量(我个人确实将其放入/etc/environment然后注销/重新登录以重新加载环境):

    ORACLE_HOME=/usr/lib/oracle/<version>/client64/lib/

    LD_LIBRARY_PATH=/usr/lib/oracle//client64/lib/

  4. 修复oracle包括:

    $ sudo ln -s /usr/include/oracle/<version>/client $ORACLE_HOME/include  # for 32bits arch, OR

    $ sudo ln -s /usr/include/oracle//client64 $ORACLE_HOME/include # for 64bits arch

  5. 创建/etc/ld.so.conf.d/oracle-instantclient<version>-basic.conf/etc/ld.so.conf.d/oracle.conf(包含最新版本,至少从12.1开始)包含:

      /lib

    /usr/lib/oracle//client/lib ; for 32bits arch, OR
    /usr/lib/oracle//client64/lib ; for 64bits arch

  6. 重新加载ldconfig缓存(-v如果需要一些详细信息,请使用标志):

    $ sudo ldconfig

您可能需要安装libaio1

如何安装cx_Oracle

假设我们已经安装了Oracle Instant Client 10,则可以使用其他方法安装cx_Oracle:

  1. 使用pip安装:($ pip install cx_oracle仅适用于Linux)
  2. 从cx_oracle PyPI站点下载installer / .tar.gz文件

较旧的版本(低于5.1.2的版本是.msi和.rpm文件)可以从此处下载。使用Alien安装RPM。例如,在撰写本文时: $ sudo alien -icx_Oracle-5.0-10g-py25-1.x86.rpm

要进行测试,python -c ''import cx_Oracle; print cx_Oracle''应返回模块及其版本。

Build and Install cx_Oracle on Mac Leopard Intel

Build and Install cx_Oracle on Mac Leopard Intel

http://www.cs.utexas.edu/~mitra/csSpring2011/cs327/cx_mac.html

Build and Install cx_Oracle on Mac Leopard Intel

I finally succeeded in building and installing cx_Oracle on a Mac. I will outline the steps that I took. There are many redundant steps that I may later take out. But there are checks that I made on the way that really helped.

The first Mac that I installed cx_Oracle was a 2.4 GHz Intel Core 2 Duo running Mac OSX 10.6.6. It had 4 GB of Memory. Most of my work was done on a terminal window.

Check Python Installation

The OSX comes with a Python interpreter. I ran a check to find the version number.

$ python -V
Python 2.6.1
This was sufficient for my needs. I decided not to upgrade to Python version 2.7.1
Xcode from Apple

The Xcode package is available from Apple Developer. You will need a login account but that is free. Now you do not need Xcode 4. Xcode 3 is sufficient because all we are interested in is the gcc compiler. After you login look for a link that says Looking for Xcode 3? I downloaded X code 3.2.6 and iOS SDK 4.3. It was 4.1 GB in size and is best done when you know you will not be using your Mac.

After the download, the installation went off smoothly. I restarted the Mac and on a terminal window checked that the gcc compiler was installed correctly.

$ which gcc
/usr/bin/gcc

$ gcc -v
gcc version 4.2.1
You can also do man gcc to get the online manual for gcc.
Install Oracle Instant Client

The cx_Oracle has a dependency. It needs Oracle Instant Client from Oracle. Click on the link Instant Client for Mac OS X (Intel x86). Accept the license agreement and download Version 10.2.0.4 (64-bit). I tried the 32-bit and it does NOT work. You will need your Oracle account to download the following packages:

instantclient-basic-10.2.0.4.0-macosx-x64.zip
instantclient-sdk-10.2.0.4.0-macosx-x64.zip
I created a directory called oracle to unpack the packages. The pathname on my machine was /Users/utcs/oracle. On your machine, it will be your user name instead of utcs. I moved both the basic and sdk packages into the oracle directory and unzipped them. After unzipping the basic package I got a folder instantclient_10_2.

After unzipping the sdk package, I got a folder called instantclient_10_2-1. Inside that folder was another folder called sdk. I moved the folder named sdk inside the folder instantclient_10_2.

From a terminal window I changed directory to sdk. On my machine, the full path name was /Users/utcs/oracle/instantclient_10_2/sdk. There is another .zip file called ottclasses.zip. I unzipped that as follows:

$ unzip ottclasses.zip
It produced a folder called oracle. I changed directory to /Users/utcs/oracle/instantclient_10_2. I ran the following command to copy all the files in the sdk folder.
$ cp -R ./sdk/* .
$ cp -R ./sdk/include/* .
The last two commands may not have been necessary. But it makes it easier to locate the header files.
Setting up the Environment Variables

In my home directory /Users/utcs I created a .profile file. Its content was as follows:

export ORACLE_HOME=/Users/utcs/oracle/instantclient_10_2
export DYLD_LIBRARY_PATH=$ORACLE_HOME
export LD_LIBRARY_PATH=$ORACLE_HOME
Restart the machine. Open another terminal window and run the following commands to check that the environment variables have been set properly:
$ source .profile
$ echo $ORACLE_HOME
$ echo $DYLD_LIBRARY_PATH
$ echo $LD_LIBRARY_PATH
You should see the path names printed out correctly. I created two symbolic links in the $ORACLE_HOME directory (/Users/utcs/oracle/instantclient_10_2) as follows:
ln -s libclntsh.dylib.10.1 libclntsh.dylib
ln -s libocci.dylib.10.1 libocci.dylib
If you run the command ls -l in that directory you should see the symbolic links.
Building and Installing cx_Oracle

Download from SourceForge cx_Oracle version 5.0.4. You need to get the package that says Source Code only. In your Download folder you will find cx_Oracle-5.0.4.tar. I moved it to /Users/utcs/oracle. To untar, I used the following command:

tar -xvf cx_Oracle-5.0.4.tar
After untarring I had a subdirectory called cx_Oracle-5.0.4. In a terminal window I changed directory to /Users/utcs/oracle/cx_Oracle-5.0.4. I checked in that window that all the environment variables were set properly by doing

echo $ORACLE_HOME
echo $LD_LIBRARY_PATH
echo $DYLD_LIBRARY_PATH
which python
which gcc
I did not have administrative privileges on this Mac so to build I did
python setup.py build
I checked to output. There were many warning messages that I ignored. Even a single error message would have indicated that the build process did not succeed. I next installed cx_Oracle by
python setup.py install
The install also finished without any error messages.
Test the cx_Oracle installation

On a terminal window type python. It should bring up Python in interactive mode. Then type import cx_Oracle. It should add the package to your path without any errors. Get out of the interactive mode using Control-D.

Now copy and paste this script into a file called Check.py. Change the user name and run it on the command line.

import cx_Oracle, string, getpass

def main():
# Get password
pswd = getpass.getpass()

# Build connection string
user = "CS327_jdoe"
host = "oracle.microlab.cs.utexas.edu"
port = "1521"
sid = "orcl"
dsn = cx_Oracle.makedsn (host, port, sid)

# Connect to Oracle and test
con = cx_Oracle.connect (user, pswd, dsn)
if (con):
print "Connection successful"
print con.version
else:
print "Connection not successful"

con.close()

main()
You should see Connection successful if all the other tests were successful.

CentOS安装python的easy_install

CentOS安装python的easy_install

直接安装easy_install不行,听说python-setuptools这个工具已经自带easy install这个了,所以直接下载setuptools就行了。

[root@localhost yum.repos.d]# yum -y install python-setuptools
结果:
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package python-setuptools.noarch 0:0.6.10-3.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                  Arch          Version               Repository   Size
================================================================================
Installing:
 python-setuptools        noarch        0.6.10-3.el6          base        336 k

Transaction Summary
================================================================================
Install       1 Package(s)

Total download size: 336 k
Installed size: 1.5 M
Downloading Packages:
python-setuptools-0.6.10-3.el6.noarch.rpm                | 336 kB     00:04     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : python-setuptools-0.6.10-3.el6.noarch                        1/1 
  Verifying  : python-setuptools-0.6.10-3.el6.noarch                        1/1 

Installed:
  python-setuptools.noarch 0:0.6.10-3.el6                                       

Complete!

再用easy_install命令安装 simplejson:

[root@localhost yum.repos.d]# easy_install simplejson
Searching for simplejson
Reading http://pypi.python.org/simple/simplejson/
Download error: [Errno 111] Connection refused -- Some packages may not be found!
Reading http://pypi.python.org/simple/simplejson/
Download error: [Errno 111] Connection refused -- Some packages may not be found!
Couldn''t find index page for ''simplejson'' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading http://pypi.python.org/simple/
Download error: [Errno 111] Connection refused -- Some packages may not be found!
No local packages or download links found for simplejson
error: Could not find suitable distribution for Requirement.parse(''simplejson'')

找不到文件,说明没有找到这个东西,安装失败。


cx_Oracle - Python Interface for Oracle Database

cx_Oracle - Python Interface for Oracle Database

cx_Oracle - Python Interface for Oracle Database

Documentation·Installation.Release Notes.Source code·Mailing list

About cx_Oracle

cx_Oracleis a Python extension module that enables access to Oracle Database. It conforms to the Python database API 2.0specificationwith a considerable number of additions and a couple of exclusions.

cx_Oracle is licensed under a BSD license which you can findhere.

cx_Oracle 6 has been tested with Python version 2.7,and with versions 3.4 and higher. You can use cx_Oracle with Oracle 11.2,12.1 and 12.2 client libraries. Oracle's standard client-server version interoperability allows connection to both older and newer databases. For example Oracle 12.2 client libraries can connect to Oracle Database 11.2 or later.

Features

  • Easily installed from PyPI.

  • Support for Python 2 and 3.

  • Support for Oracle Client 11.2,12.1 and 12.2. Oracle's standard cross-version interoperability,allows easy upgrades and connectivity to different Oracle Database versions.

  • Connect to Oracle Database 9.2,10,11 or 12 (depending on the Oracle Client version used).

  • sql and PL/sql Execution. The underlying Oracle Client libraries have significant optimizations including compressed fetch,pre-fetching,client and server result set caching,and statement caching with auto-tuning.

  • Full use of Oracle Network Service infrastructure,including encrypted network traffic and security features.

  • Extensive Oracle data type support,including large object support (CLOB and BLOB).

  • Direct binding to sql objects. One great use case is binding Python objects to Oracle Spatial SDO objects.

  • Array operations for efficient INSERT and UPDATEs.

  • Array row counts and batch error handling for array operations.

  • Fetching of large result sets.

  • REF CURSOR support.

  • Support for scrollable cursors. Go back and forth through your query results.

  • Fetch PL/sql Implicit Results. Easily return query results from PL/sql.

  • Row Prefetching. Efficient use of the network.

  • Client Result Caching. Improve performance of frequently executed look-up statements.

  • Support for Advanced Queuing. Use database notifications to build micro-service applications.

  • Continuous Query Notification. Get notified when data changes.

  • Support for Edition Based RedeFinition. Easily switch applications to use updated PL/sql logic.

  • Support for setting application context during the creation of a connection,making application Metadata more accessible to the database,including in logoN triggers.

  • End-to-end monitoring and tracing.

  • Transaction Management.

  • Session Pooling.

  • Database Resident Connection Pooling (DRCP).

  • Privileged Connections.

  • External Authentication.

  • Database startup and shutdown.

  • Oracle Database High Availability Features,such as FAN notifications and Transaction Guard support.

DB API specification exclusions: The time data type is not supported by Oracle and is therefore not implemented. The methodcursor.nextset()is not implemented either as the DB API specification assumes an implementation of cursors that does not fit well with Oracle's implementation of cursors and implicit results. See the methodcursor.getimplicitresults()for more information.

Installation

Seecx_Oracle Installationfor detailed instructions.

  • The simplest way to install cx_Oracle is with pip:

    python -m pip install cx_Oracle --upgrade

    If a binary wheel package is not available onPyPIfor your platform,the source package will be used.

    Note that if you download a source zip file directly from GitHub then you will also need to download anODPI-Csource zip file and extract it inside the directory called "odpi".

  • After cx_Oracle is installed,Oracle client libraries must also be installed and configured. These can be from Oracle Instant Client,from a local Oracle Database,or from a full Oracle Client installation.

    If you need the libraries,download and unzip theOracle Instant Client'Basic' package for your platform and set PATH,LD_LIBRARY_PATH,or similar platform-specific library path loading environment. See theinstallation notes for ODPI-Cfor help.

    Versions 11.2,12.1 and 12.2 of the Oracle Client libraries on Linux,Windows and macOS are supported. Users have also reported success with other platforms.

If you require cx_Oracle 5.3,download a Windows installer fromPyPIor usepython -m pip install cx-oracle==5.3to install from source.

Very old versions of cx_Oracle can be found in the files section atSourceforge.

Example

from __future__ import print_function

    import cx_Oracle

    connection = cx_Oracle.connect("hr","welcome","localhost/orclpdb")

    cursor = connection.cursor()
    cursor.execute("""
	    SELECT first_name,last_name
	    FROM employees
	    WHERE department_id = :did AND employee_id > :eid""",did = 50,eid = 190)
    for fname,lname in cursor:
	print("Values:",fname,lname)

For more examples,please see thesamplesand thetest suite. You can also look at the scripts incx_OracleToolsand the modules incx_PyOracleLib.

Documentation

See thecx_Oracle DocumentationandRelease Notes.

Help

Issues and questions can be raised with the cx_Oracle community onGitHubor on themailing list.

easy_install cx_Oracle(python包)在Windows上

easy_install cx_Oracle(python包)在Windows上

所以我发现 Help installing cx_Oracle,但仍然卡住了.我从oracle下载了最新的instantclient,并将ORACLE_HOME设置为提取的文件的位置(两者都直接和一个bin文件夹在ORACLE_HOME值和文件之间),但是easy_install在运行setup.py时会弹出一个错误,定位Oracle包含文件.我确实注意到,只有11g的dll在文件夹中,我需要所有3个驱动程序存在安装完成?如果是这样,我甚至可以得到他们?
老实说,从他们拥有的 binary installers之一,而不是从源代码安装cx_Oracle更是容易一些.

* nix的HOWTO:

>浏览至Instant Client for Linux x86 download page.
>下载适合您架构(32或64位)的最新版本的基本sqlplus和sdk软件包:

> oracle-instantclient< version> -basic-< version_full>.< arch> .rpm
> oracle-instantclient< version> -sqlplus-< version_full>.< arch> .rpm
> oracle-instantclient< version> -devel-< version_full>.< arch> .rpm.

>使用外来人员安装RPM.例如,在撰写本文时:

$sudo alien -i oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm

>添加必要的环境变量(我个人把它放在/ etc / environment然后注销/重新加载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

>创建/etc/ld.so.conf.d/oracle-instantclient\u0026lt;version\u0026gt;-basic.conf和/etc/ld.so.conf.d/oracle.conf(对于更新的版本,至少自12.1)包含:

/lib  
  /usr/lib/oracle/<version>/client/lib  ; for 32bits arch,OR
  /usr/lib/oracle/<version>/client64/lib  ; for 64bits arch

>重新加载ldconfig缓存(如果你想要一些verbose,使用-v标志):

$sudo ldconfig

您可能需要安装libaio1.

HOWTO安装cx_Oracle

假设我们已经安装了Oracle Instant Client 10,则可以使用不同的安装方式cx_Oracle:

>安装pip:$pip install cx_oracle(仅限linux)
>从cx_oracle PyPI站点下载installer / .tar.gz文件

旧版本(版本小于5.1.2是.msi和.rpm文件)可以从here下载.使用外来人员安装RPM.例如,在撰写本文时:
$sudo alien -i cx_Oracle-5.0-10g-py25-1.x86.rpm

要测试,python -c’import cx_Oracle; print cx_Oracle’应该返回带有其版本的模块.

今天的关于Windows上的easy_install cx_OraclePython软件包的分享已经结束,谢谢您的关注,如果想了解更多关于Build and Install cx_Oracle on Mac Leopard Intel、CentOS安装python的easy_install、cx_Oracle - Python Interface for Oracle Database、easy_install cx_Oracle(python包)在Windows上的相关知识,请在本站进行查询。

本文标签: