遇到的问题如下,这个问题倒腾了好几天

以下是oracle服务器的版本信息,,所以相应的客户端也要用以下版本的

1、下载文件如下两个文件

https://www.oracle.com/technetwork/topics/intel-macsoft-096467.html

(163邮箱-123456Aa)

2、创建目录如下图,并把以上下载的的两个文件都解压到图中的文件夹内

3、继续创建lib文件夹,见下图,并放三个文件进去

就这一步卡了好久,一直没有放3个文件到lib中所以一直提示开始时的错误wuwu

参考https://oracle.github.io/odpi/doc/installation.html#macos:

ODPI-C requires Oracle Client libraries, which are found in Oracle Instant Client for macOS.

On macOS, ODPI-C first searches for a library called “libclntsh.dylib” using the standard library search order. If this is not found, it will then search for “libclntsh.dylib.18.1”, “libclntsh.dylib.12.1” and then for “libclntsh.dylib.11.1” before returning an error.

To run ODPI-C applications with Oracle Instant Client zip files:

Download the 18, 12, or 11.2 “Basic” or “Basic Light” zip file from here. Choose either a 64-bit or 32-bit package, matching your application architecture. Most applications use 64-bit.

Unzip the package into a single directory that is accessible to your application. For example:

mkdir -p /opt/oracle

unzip instantclient-basic-macos.x64-12.2.0.1.0.zip

Add links to $HOME/lib or /usr/local/lib to enable applications to find the library. For example:

mkdir ~/lib

ln -s /opt/oracle/instantclient_12_2/libclntsh.dylib.12.1 ~/lib/

Alternatively, copy the required OCI libraries. For example:

mkdir ~/lib

cp /opt/oracle/instantclient_12_2/{libclntsh.dylib.12.1,libclntshcore.dylib.12.1,libons.dylib,libnnz12.dylib,libociei.dylib} ~/lib/

For Instant Client 11.2, the OCI libraries must be copied. For example:

mkdir ~/lib

cp /opt/oracle/instantclient_11_2/{libclntsh.dylib.11.1,libnnz11.dylib,libociei.dylib} ~/lib/

If you intend to co-locate optional Oracle configuration files such as tnsnames.ora, sqlnet.ora or oraaccess.xml with Instant Client, then create a network/admin subdirectory, if it does not exist. For example:

mkdir -p /opt/oracle/instantclient_12_2/network/admin

This is the default Oracle configuration directory for applications linked with this Instant Client.

Alternatively, Oracle configuration files can be put in another, accessible directory. Then set the environment variable TNS_ADMIN to that directory name.

To run ODPI-C applications on other platforms (such as Solaris and AIX), follow the same general directions as for Linux Instant Client zip files or Local Database. Add the Oracle libraries to the appropriate library path variable, such as LD_LIBRARY_PATH on Solaris, or LIBPATH on AIX.

4、配置环境变量

- [x] localhost:~ ligaijiang$ open -e .bash_profile

export PATH=$PATH;

### oracle client

#export DYLD_LIBRARY_PATH=/Users/ligaijiang/Documents/instantclient:$PATH

#export ORACLE_HOME=/Users/ligaijiang/Documents/instantclient

#export SQLPATH=$ORACLE_HOME

#export PATH=$DYLD_LIBRARY_PATH:$ORACLE_HOME:SQLPATH:$PATH

export ORACLE_HOME=/Users/ligaijiang/oracle/instantclient_11_2

export DYLD_LIBRARY_PATH=$ORACLE_HOME

export LD_LIBRARY_PATH=$ORACLE_HOME

export PATH=~/instantclient_11_2:$PATH

export PATH=$DYLD_LIBRARY_PATH:$ORACLE_HOME:SQLPATH:$PATH

#export ORACLE_HOME=/Users/ligaijiang/oracle/instantclient_11_2

#export DYLD_LIBRARY_PATH=$ORACLE_HOME

#export LD_LIBRARY_PATH=$ORACLE_HOME

export NLS_LANG=AMERICAN_AMERICA.UTF8

#export TNS_ADMIN=$HOME/etc

#export PATH=$PATH:$ORACLE_HOME

- [x] localhost:~ ligaijiang$ source .bash_profile

至此oracle客户端基本安装完成,验证是否安装成功:

验证oracle客户端是否安装成功————————————————————————————

- [x] localhost:~ ligaijiang$ echo $ORACLE_HOME

echo /Users/ligaijiang/oracle/instantclient_11_2

验证sqlplus是否安装成功————————————————————————————

- [x] localhost:~ ligaijiang$ sqlplus

SQL*Plus: Release 11.2.0.4.0 Production on Fri Jan 11 10:35:06 2019

Copyright (c) 1982, 2013, Oracle. All rights reserved.

Enter user-name: finse

localhost:~ ligaijiang$ sqlplus finser/finser2015X@//10.139.39.43:1524/sjw2

SQL*Plus: Release 11.2.0.4.0 Production on Mon Jan 14 11:29:15 2019

Copyright (c) 1982, 2013, Oracle. All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select t.* from CLEA_BANK_BIND_INFO t where phone_no = '18200717087';

5、安装cx_Oracle

https://pypi.org/project/cx_Oracle/

#files

解压缩后放后放python安装路径下的这里

卸载安装cx_Oracle模————————————————————————————

- [x] localhost:~ ligaijiang$ pip uninstall cx_Oracle

Uninstalling cx-Oracle-7.0.0:

Would remove:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cx_Oracle-7.0.0-py3.7-macosx-10.9-x86_64.egg

Proceed (y/n)? y

Successfully uninstalled cx-Oracle-7.0.0

- [x] localhost:~ ligaijiang$ cd /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cx_Oracle-7.0.0

- [x] localhost:cx_Oracle-7.0.0 ligaijiang$ python setup.py build

- [x] localhost:cx_Oracle-7.0.0 ligaijiang$ python setup.py install

6、解决乱码的问题

#代码前添加这两行

importos

os.environ['NLS_LANG'] = 'SIMPLIFIED CHINESE_CHINA.UTF8'

python连接数据库oracle_python连接oracle数据库相关推荐

  1. python连接数据库oracle_python 连接oracle数据库:cx_Oracle

    注意:64位操作系统必须安装64位oracle客户端,否则会连接报错 安装第三方库:cx_Oracle 一.连接数据库的三种方式: 1.cx_Oracle.connect('账号/密码@ip:端口/数 ...

  2. python实时连接oracle_python连接oracle数据库

    在python连接oracle数据库时走了不少弯路,主要是版本问题.下面记录一下安装时遇到的版本问题 pthon连接oracle需要先引入cx_Oracle模块 1.从官网下载https://pypi ...

  3. python访问数据库oracle_python连接oracle数据库

    结合自己公司项目练练手数据库这块的操作. 我公司所有项目均使用oracle数据库,就需要先安装oracle相关的.whl文件.在网上找了一些关于"python连接数据库"的相关帖子 ...

  4. python直接连接oracle_python连接oracle

    一:弄清版本,最重要!!! 首先安装配置时,必须把握一个点,就是版本一致!包括:系统版本,python版本,oracle客户端的版本,cx_Oracle的版本,然后安装配置就容易了! 二:安装 1.c ...

  5. java oracle连接数据库_Java 连接 Oracle 数据库

    importjava.security.interfaces.RSAKey;import oracle.jdbc.*;import java.sql.*;public classTestOracle ...

  6. Python 技术篇-连接oracle数据库并执行sql语句实例演示,python连接oracle数据库oci详细配置方法

    Python 连接 Oracle 数据库 第一章:连接 oracle 数据与环境配置 ① 连接 oracle 数据库效果演示 ② oci 下载 ③ oci 配置 ④ 环境变量配置 ⑤ 检测是否有 or ...

  7. python cx_Oracle连接Oracle数据库查询

    python cx_Oracle连接Oracle数据库查询 代码 带参数查询 官方文档地址 代码 import cx_Oracle import pandas as pdsql = ''' SELEC ...

  8. python读取oracle数据库中文乱码_PL/SQL连接Oracle数据库,中文乱码,显示问号

    PL/SQL连接oracle数据库 1.简单介绍 在不安装oracle数据库的情况下使用pl/sql连接远程oracle数据库. 2.详细步骤: a)      安装PL/SQL.依据自己的操作系统安 ...

  9. python连接oracle数据库 插入clob类型数据

    python连接oracle数据库 插入clob类型数据 连接数据库 import cx_Oracle as cx #导入模块 con = cx.connect('root', 'root123', ...

最新文章

  1. John的农场(最小生成树)
  2. 深度学习综述(LeCun、Bengio和Hinton)
  3. c语言中div函数,C 库函数
  4. VTK:PolyData之RemoveVertices
  5. java ee 导入项目_最代码网站java项目下载后遇到项目打开,导入,运行的问题QA汇总...
  6. 发现一个 WPF/E Asp.net Server Control
  7. BA-风阀水阀执行器接线图
  8. 使用OpenSSL转换X509 PEM与PFX证书
  9. DTD与XML的关系。。说的不错,拿来看看,学习了
  10. linux进入root编译gcc,非Root用户编译安装GCC
  11. 老版资源嗅探浏览器 - 遨游浏览器稀有绿色版
  12. 洛谷oj---1036 选数
  13. 超频到3200最佳时序_ddr4内存时序多少为好
  14. IOS通过加速感应器实现手机实现手机屏幕上的足球可以来回的滚动反弹
  15. Google, with new Pixel and camera, is serious about devices
  16. 网管、桌面运维、技术支持 有出路吗
  17. 如何使用Kotlin构建Android旋转旋钮以帮助儿子练习钢琴
  18. 2021十大手表品牌TOP排行榜
  19. unity.生成表示地图信息的二维数组_Unity3D 中生成任意形状3D Texture amp; 体积云...
  20. thymeleaf模板引擎: org.xml.sax.SAXParseException: 在实体引用中, 实体名称必须紧跟在 '' 后面。

热门文章

  1. [ACM]HDU Problem 2000 + Java
  2. CF938G Shortest Path Queries
  3. JS判断IE6/IE7/IE8系列的写法
  4. Centos镜像使用帮助
  5. silverlight 通过WCF与LinQ对数据库进行操作1
  6. COM组件设计与应用(三)(转载)
  7. Gentle.NET 使用文档
  8. 伦敦帝国学院提出局部特征提取新模式D2D:先描述后检测
  9. 6 篇 2019 年最新模型剪枝技术合集
  10. CVPR 2019 | Adobe提出新型超分辨率方法:用神经网络迁移参照图像纹理