我已经安装了 cx_Oracle 来连接 Python 和 Oracle 进行编程;但是,如果我在 cx_Oracle 所在的目录中,我只能将 cx_Oracle 导入 python。如何全局导入 cx_Oracle?下面是演示问题的代码。
谢谢你的帮助。
Python 无法导入 cx_Oracle
user@T420 ~ $ python
Python 2.7.3 (default, Sep 26 2012, 21:51:14)
[GCC 4.7.2] on linux2
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
Python可以从它所在的目录导入cx_Oracle
user@T420 /usr/lib/python2.7/site-packages $ ls
cx_Oracle-5.1.2-py2.7.egg-info cx_Oracle.so
user@T420 /usr/lib/python2.7/site-packages $ python
Python 2.7.3 (default, Sep 26 2012, 21:51:14)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle
>>>