ImportError: No module named 'cx_Oracle'问题处理过程记录,安装python cx_Oracle库 - Go语言中文社区

ImportError: No module named 'cx_Oracle'问题处理过程记录,安装python cx_Oracle库


错误如下:

E:pargram>python
Python 3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul  5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information. >>> import cx_Oracle Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named 'cx_Oracle'

执行过

  pip install cx_Oracle


也试过离线包

E:pargram>pip install cx_Oracle-7.1.3-cp35-cp35m-win_amd64.whl
Processing e:pargramcx_oracle-7.1.3-cp35-cp35m-win_amd64.whl
Installing collected packages: cx-Oracle
Successfully installed cx-Oracle-7.1.3

还是报错。

最后只能选择
安装cx_Oracle-7.1.3.tar.gz
执行python setup.py install
报错如下:

cxoModule.obj : warning LNK4197: export 'PyInit_cx_Oracle' specified multiple times; 

using first specification   Creating library buildtemp.win-amd64-3.5Releasesrccx_Oracle.cp35-win_amd64.lib 

and object buildtemp.win-amd64-3.5

Releasesrccx_Oracle.cp35-win_amd64.expGenerating codeFinished generating code

LINK : fatal error LNK1158: cannot run 'rc.exe'

error: command 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64

\link.exe' failed with exit status 1158

解决办法:
把目录C:Program Files (x86)Windows Kits8.1binx86目录下rc.exe(还是不行加上rcdll.dll)
拷贝到C:Program Files (x86)Microsoft Visual Studio 14.0VCbin目录下。
在执行python setup.py install后可以了。


可是import cx_Oracle

D:>pythonPython 3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul  5 2016, 11:41:13)

 [MSC v.1900 64 bit (AMD64)] on win32Type "help", "copyright", "credits" or "license" for 

more information.

>>> import cx_Oracle

但是

>>> conn=cx_Oracle.connect('scott/scott@192.168.48.102:1521/orcl')

Traceback (most recent call last):  File "<stdin>", line 1, in <module>cx_Oracle.DatabaseError: 

Error while trying to retrieve text for error ORA-01804
>>>

发现应该是Oracle client问题。

安装了oracle11g client终于成功了

简单验证:

E:>python

Python 3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul  5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)] on win32

Type "help", "copyright", "credits" or "license" for more information.

>>> import cx_Oracle

>>> conn=cx_Oracle.connect('scott/scott@192.168.48.102:1521/orcl')

>>> curs=conn.cursor()

>>> sql='select * from dept'

>>> curs.execute (sql)

>>> row=curs.fetchone()

>>> print(row[0])

10

>>> print(row[1])

ACCOUNTING

>>> curs.close()

>>> conn.close()

 

 

转载于:https://www.cnblogs.com/fameg/p/11117282.html

版权声明:本文来源CSDN,感谢博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/weixin_30470643/article/details/102114890
站方申明:本站部分内容来自社区用户分享,若涉及侵权,请联系站方删除。
  • 发表于 2020-06-30 08:32:41
  • 阅读 ( 1728 )
  • 分类:

0 条评论

请先 登录 后评论

官方社群

GO教程

猜你喜欢