我正在尝试使用cx_Oracle模块将Python与我的Oracle数据库连接起来。我试着在最近几个小时安装它,但找不到我的问题的答案。
使用pip install cx_oracle
Collecting cx_oracle
Using cached cx_Oracle-5.2.1.tar.gz
Building wheels for collected packages: cx-oracle
Running setup.py bdist_wheel for cx-oracle ... error
Complete output from command /Users/dunker/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/x2/shhmzq692yx16cmgnmm8wgqm0000gn/T/pip-build-u1fc6kgz/cx-oracle/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /var/folders/x2/shhmzq692yx16cmgnmm8wgqm0000gn/T/tmpdol0yxgqpip-wheel- --python-tag cp35:
running bdist_wheel
running build
running build_ext
building 'cx_Oracle' extension
creating build
creating build/temp.macosx-10.6-x86_64-3.5-12c
/usr/bin/clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/dunker/anaconda3/include -arch x86_64 -I/Library/Oracle/instantclient_11_2/sdk/include -I/Users/dunker/anaconda3/include/python3.5m -c cx_Oracle.c -o build/temp.macosx-10.6-x86_64-3.5-12c/cx_Oracle.o -DBUILD_VERSION=5.2.1
In file included from cx_Oracle.c:203:
In file included from ./SessionPool.c:138:
In file included from ./Connection.c:761:
In file included from ./Cursor.c:246:
In file included from ./Variable.c:171:
./NumberVar.c:372:26: warning: absolute value function 'abs' given an argument of type 'long' but has parameter of type 'int' which may cause truncation of value [-Wabsolute-value]
length = numDigits + abs(scale) + 3;
^
./NumberVar.c:372:26: note: use function 'labs' instead
length = numDigits + abs(scale) + 3;
^~~
labs
In file included from cx_Oracle.c:203:
In file included from ./SessionPool.c:138:
In file included from ./Connection.c:761:
In file included from ./Cursor.c:246:
In file included from ./Variable.c:176:
./ObjectVar.c:118:19: warning: comparison of integers of different signs: 'int' and 'ub4' (aka 'unsigned int') [-Wsign-compare]
for (i = 0; i < self->allocatedElements; i++) {
~ ^ ~~~~~~~~~~~~~~~~~~~~~~~
./ObjectVar.c:135:19: warning: comparison of integers of different signs: 'int' and 'ub4' (aka 'unsigned int') [-Wsign-compare]
for (i = 0; i < self->allocatedElements; i++) {
~ ^ ~~~~~~~~~~~~~~~~~~~~~~~
In file included from cx_Oracle.c:203:
In file included from ./SessionPool.c:138:
In file included from ./Connection.c:761:
In file included from ./Cursor.c:246:
./Variable.c:926:32: warning: comparison of integers of different signs: 'ub4' (aka 'unsigned int') and 'int' [-Wsign-compare]
if (var->allocatedElements < cursor->fetchArraySize) {
~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~
In file included from cx_Oracle.c:203:
In file included from ./SessionPool.c:138:
In file included from ./Connection.c:761:
./Cursor.c:2440:19: warning: comparison of integers of different signs: 'int' and 'ub4' (aka 'unsigned int') [-Wsign-compare]
for (i = 0; i < rowCountArraySize; i++) {
~ ^ ~~~~~~~~~~~~~~~~~
In file included from cx_Oracle.c:203:
In file included from ./SessionPool.c:138:
In file included from ./Connection.c:764:
./Subscription.c:451:19: warning: comparison of integers of different signs: 'ub4' (aka 'unsigned int') and 'sb4' (aka 'int') [-Wsign-compare]
for (i = 0; i < numRows; i++) {
~ ^ ~~~~~~~
./Subscription.c:526:19: warning: comparison of integers of different signs: 'ub4' (aka 'unsigned int') and 'sb4' (aka 'int') [-Wsign-compare]
for (i = 0; i < numTables; i++) {
~ ^ ~~~~~~~~~
./Subscription.c:618:23: warning: comparison of integers of different signs: 'ub4' (aka 'unsigned int') and 'sb4' (aka 'int') [-Wsign-compare]
for (i = 0; i < numTables; i++) {
~ ^ ~~~~~~~~~
./Subscription.c:660:23: warning: comparison of integers of different signs: 'ub4' (aka 'unsigned int') and 'sb4' (aka 'int') [-Wsign-compare]
for (i = 0; i < numQueries; i++) {
~ ^ ~~~~~~~~~~
**9 warnings generated.**
creating build/lib.macosx-10.6-x86_64-3.5-12c
/usr/bin/clang -bundle -undefined dynamic_lookup -L/Users/dunker/anaconda3/lib -arch x86_64 build/temp.macosx-10.6-x86_64-3.5-12c/cx_Oracle.o -L/Library/Oracle/instantclient_11_2 -L/Users/dunker/anaconda3/lib -lclntsh -o build/lib.macosx-10.6-x86_64-3.5-12c/cx_Oracle.cpython-35m-darwin.so -shared-libgcc
ld: library not found for -lclntsh
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command '/usr/bin/clang' failed with exit status 1
----------------------------------------
Failed building wheel for cx-oracle
Running setup.py clean for cx-oracle
Failed to build cx-oracle
Installing collected packages: cx-oracle
Running setup.py install for cx-oracle ... error
Complete output from command /Users/dunker/anaconda3/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/x2/shhmzq692yx16cmgnmm8wgqm0000gn/T/pip-build-u1fc6kgz/cx-oracle/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/x2/shhmzq692yx16cmgnmm8wgqm0000gn/T/pip-jk8j3nz6-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_ext
building 'cx_Oracle' extension
creating build
creating build/temp.macosx-10.6-x86_64-3.5-12c
/usr/bin/clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/dunker/anaconda3/include -arch x86_64 -I/Library/Oracle/instantclient_11_2/sdk/include -I/Users/dunker/anaconda3/include/python3.5m -c cx_Oracle.c -o build/temp.macosx-10.6-x86_64-3.5-12c/cx_Oracle.o -DBUILD_VERSION=5.2.1
In file included from cx_Oracle.c:203:
In file included from ./SessionPool.c:138:
In file included from ./Connection.c:761:
In file included from ./Cursor.c:246:
In file included from ./Variable.c:171:
./NumberVar.c:372:26: warning: absolute value function 'abs' given an argument of type 'long' but has parameter of type 'int' which may cause truncation of value [-Wabsolute-value]
length = numDigits + abs(scale) + 3;
^
./NumberVar.c:372:26: note: use function 'labs' instead
length = numDigits + abs(scale) + 3;
^~~
labs
In file included from cx_Oracle.c:203:
In file included from ./SessionPool.c:138:
In file included from ./Connection.c:761:
In file included from ./Cursor.c:246:
In file included from ./Variable.c:176:
./ObjectVar.c:118:19: warning: comparison of integers of different signs: 'int' and 'ub4' (aka 'unsigned int') [-Wsign-compare]
for (i = 0; i < self->allocatedElements; i++) {
~ ^ ~~~~~~~~~~~~~~~~~~~~~~~
./ObjectVar.c:135:19: warning: comparison of integers of different signs: 'int' and 'ub4' (aka 'unsigned int') [-Wsign-compare]
for (i = 0; i < self->allocatedElements; i++) {
~ ^ ~~~~~~~~~~~~~~~~~~~~~~~
In file included from cx_Oracle.c:203:
In file included from ./SessionPool.c:138:
In file included from ./Connection.c:761:
In file included from ./Cursor.c:246:
./Variable.c:926:32: warning: comparison of integers of different signs: 'ub4' (aka 'unsigned int') and 'int' [-Wsign-compare]
if (var->allocatedElements < cursor->fetchArraySize) {
~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~
In file included from cx_Oracle.c:203:
In file included from ./SessionPool.c:138:
In file included from ./Connection.c:761:
./Cursor.c:2440:19: warning: comparison of integers of different signs: 'int' and 'ub4' (aka 'unsigned int') [-Wsign-compare]
for (i = 0; i < rowCountArraySize; i++) {
~ ^ ~~~~~~~~~~~~~~~~~
In file included from cx_Oracle.c:203:
In file included from ./SessionPool.c:138:
In file included from ./Connection.c:764:
./Subscription.c:451:19: warning: comparison of integers of different signs: 'ub4' (aka 'unsigned int') and 'sb4' (aka 'int') [-Wsign-compare]
for (i = 0; i < numRows; i++) {
~ ^ ~~~~~~~
./Subscription.c:526:19: warning: comparison of integers of different signs: 'ub4' (aka 'unsigned int') and 'sb4' (aka 'int') [-Wsign-compare]
for (i = 0; i < numTables; i++) {
~ ^ ~~~~~~~~~
./Subscription.c:618:23: warning: comparison of integers of different signs: 'ub4' (aka 'unsigned int') and 'sb4' (aka 'int') [-Wsign-compare]
for (i = 0; i < numTables; i++) {
~ ^ ~~~~~~~~~
./Subscription.c:660:23: warning: comparison of integers of different signs: 'ub4' (aka 'unsigned int') and 'sb4' (aka 'int') [-Wsign-compare]
for (i = 0; i < numQueries; i++) {
~ ^ ~~~~~~~~~~
9 warnings generated.
creating build/lib.macosx-10.6-x86_64-3.5-12c
/usr/bin/clang -bundle -undefined dynamic_lookup -L/Users/dunker/anaconda3/lib -arch x86_64 build/temp.macosx-10.6-x86_64-3.5-12c/cx_Oracle.o -L/Library/Oracle/instantclient_11_2 -L/Users/dunker/anaconda3/lib -lclntsh -o build/lib.macosx-10.6-x86_64-3.5-12c/cx_Oracle.cpython-35m-darwin.so -shared-libgcc
ld: library not found for -lclntsh
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command '/usr/bin/clang' failed with exit status 1
我收到此类错误消息。我按照了10多个教程,但似乎无法找到答案。设置env变量是正确的,其他一切都正常。
答案 0 :(得分:1)
好的,我发现了错误:
在我的情况下转到ln -s libclntsh.dylib.12.1 libclntsh.dylib
它是/ library / oracle / instantclient_11_2
pip install --no-cache-dir --allow-external --allow-unverified cx_oracle
然后
for
为我工作。