加入收藏 | 设为首页 | 会员中心 | 我要投稿 PHP编程网 - 黄冈站长网 (http://www.0713zz.com/)- 数据应用、建站、人体识别、智能机器人、语音技术!
当前位置: 首页 > 百科 > 正文

ImportError: No module named #39;cx_Oracle#39;问题处理

发布时间:2021-01-20 08:46:58 所属栏目:百科 来源:网络整理
导读:错误如下: E:pargrampythonPython 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_OracleTraceback (most rec

错误如下:

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.0VCBINx86_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,11:41:13)

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

more information.

>>> import cx_Oracle

但是

>>> conn=cx_Oracle.connect(‘scott/[email?protected]:1521/orcl‘)

Traceback (most recent call last):  File "<stdin>",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,11:41:13) [MSC v.1900 64 bit (AMD64)] on win32

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

>>> import cx_Oracle

>>> conn=cx_Oracle.connect(‘scott/[email?protected]: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()

?

ImportError: No module named #39;cx_Oracle#39;问题处理

(编辑:PHP编程网 - 黄冈站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读