python连phoenix遇到很多坑
根据网上代码
import jaydebeapi
jdbc_driver = "org.apache.phoenix.jdbc.PhoenixDriver"
jdbc_url="jdbc:phoenix1:xxx,xxx2,xxx3:2181"
phoenix_client_jar="/home/xxx/AI_check/phoenix-4.14.3-HBase-1.3-client.jar"
conn = jaydebeapi.connect(jdbc_driver,jdbc_url,[ '', ''],
phoenix_client_jar)
然后报错(第一个坑):
""")
Traceback (most recent call last):
File "E:/PycharmProjects/untitled/tab_check/jay_conn.py", line 32, in <module>
phoenix_client_jar)
File "D:\Anaconda3\envs\tensorflow_gpu\lib\site-packages\jaydebeapi\__init__.py", line 381, in connect
jconn = _jdbc_connect(jclassname, url, driver_args, jars, libs)
File "D:\Anaconda3\envs\tensorflow_gpu\lib\site-packages\jaydebeapi\__init__.py", line 182, in _jdbc_connect_jpype
for i in types.__javaclass__.getClassFields():
AttributeError: type object 'java.sql.Types' has no attribute '__javaclass__'
通过Google显示需要降低jpype1的版本到0.6.3(百度根本没用找不到答案)
然后pip install jpype1==0.6.3再报错(截取一部分)
大致原因是gcc编码相关的:
/home/teestflow/anaconda3/bin/x86_64-conda_cos6-linux-gnu-cc -Wno-unused-result -Wsign-compare -DNDEBUG -fwrapv -O2 -Wall -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pe -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/teestflow/anaconda3/incde -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/teestflow/anaconda3/include -fPIC -DHAVE_NUMPY=1 -Inative/common/include -Inative/python/include -I/usr/lal/jdk/include -I/usr/local/jdk/include/linux -I/home/teestflow/anaconda3/lib/python3.7/site-packages/numpy/core/include -I/home/teestflow/anaconda3/includeython3.7m -c native/common/jp_array.cpp -o build/temp.linux-x86_64-3.7/native/common/jp_array.o -ggdb
x86_64-conda_cos6-linux-gnu-cc: error trying to exec 'cc1plus': execvp: No such file or directory
error: command '/home/teestflow/anaconda3/bin/x86_64-conda_cos6-linux-gnu-cc' failed with exit status 1
----------------------------------------
Rolling back uninstall of JPype1
Moving to /home/teestflow/anaconda3/lib/python3.7/site-packages/JPype1-0.7.4.dist-info/
from /home/teestflow/anaconda3/lib/python3.7/site-packages/~Pype1-0.7.4.dist-info
Moving to /home/teestflow/anaconda3/lib/python3.7/site-packages/_jpype.cpython-37m-x86_64-linux-gnu.so
from /tmp/pip-uninstall-vwqx_cvi/_jpype.cpython-37m-x86_64-linux-gnu.so
Moving to /home/teestflow/anaconda3/lib/python3.7/site-packages/jpype/
from /home/teestflow/anaconda3/lib/python3.7/site-packages/~pype
ERROR: Command errored out with exit status 1: /home/teestflow/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-insll-byc40g31/jpype1/setup.py'"'"'; __file__='"'"'/tmp/pip-install-byc40g31/jpype1/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.re().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-ekmc8xg9/install-record.t --single-version-externally-managed --compile Check the logs for full command output.
然后conda install gxx_linux-64,conda install gcc_linux-64 安装gxx,gcc。
再pip install jpype1==0.6.3就成功了安装了,