工作需要,在阿里云的服務器(CentOS 6)上裝Cassandra.
裝Cassandra本身倒是沒什么大問題,問題出在后來用python。
首先是python 2.6好像不支持,于是升級到python2.7。
參考:
之后好不容易弄好了環境,裝好了pip,結果pip install cqlsh上就卡死了。
查了一圈谷歌,
http://blog.csdn.net/counsellor/article/details/52026234
http://www.cnblogs.com/zjutzz/p/5716251.html
都有啟發。
首先看卡死的地方:
$ pip install cqlsh
Collecting cqlsh
Downloading http://mirrors.aliyuncs.com/pypi/packages/12/a7/13aff4ad358ff4abef6823d872154d0955ff6796739fcaaa2c80a6940aa6/cqlsh-5.0.3.tar.gz (99kB)
100% |████████████████████████████████| 102kB 1.6MB/s
Requirement already satisfied: cql in /usr/local/lib/python2.7/site-packages (from cqlsh)
Requirement already satisfied: simplejson in /usr/local/lib/python2.7/site-packages (from cqlsh)
Requirement already satisfied: unittest2 in /usr/local/lib/python2.7/site-packages (from cqlsh)
Collecting cassandra-driver (from cqlsh)
Downloading http://mirrors.aliyuncs.com/pypi/packages/82/db/f5ee4f417b6ed7abf2967dbb249ec1ed9cafb1007cfbe9e6b8c0d6e5d6b4/cassandra-driver-3.7.1.tar.gz (211kB)
100% |████████████████████████████████| 215kB 752kB/s
Requirement already satisfied: thrift in /usr/local/lib/python2.7/site-packages (from cql->cqlsh)
Requirement already satisfied: argparse in /usr/local/lib/python2.7/site-packages (from unittest2->cqlsh)
Requirement already satisfied: six>=1.4 in /usr/local/lib/python2.7/site-packages (from unittest2->cqlsh)
Requirement already satisfied: traceback2 in /usr/local/lib/python2.7/site-packages (from unittest2->cqlsh)
Requirement already satisfied: futures in /usr/local/lib/python2.7/site-packages (from cassandra-driver->cqlsh)
Requirement already satisfied: linecache2 in /usr/local/lib/python2.7/site-packages (from traceback2->unittest2->cqlsh)
Installing collected packages: cassandra-driver, cqlsh
Running setup.py install for cassandra-driver ... -^canceled
Operation cancelled by user
知道是cassandra-driver卡死,從阿里云直接下過來解壓看,發現果然是這貨去官方源了。
ez_setup.py Line 32
DEFAULT_URL = https://pypi.python.org/packages/source/s/setuptools/"
編輯此處, 改成阿里云的源:
DEFAULT_URL = "https://mirrors.aliyuncs.com/pypi/packages/source/s/setuptools/"
保存。
之后本地運行python setup.py install 發現還是不行:
$ python setup.py install
Unable to find pgen, not compiling formal grammar.
warning: no files found matching '*.pyx' under directory 'Cython/Debugger/Tests'
warning: no files found matching '*.pxd' under directory 'Cython/Debugger/Tests'
warning: no files found matching '*.h' under directory 'Cython/Debugger/Tests'
warning: no files found matching '*.pxd' under directory 'Cython/Utility'
看樣子是Cython沒裝,于是先裝Cython。
$ pip install Cython
Collecting Cython
Downloading http://mirrors.aliyuncs.com/pypi/packages/f2/e3/ca916bbdf7c55225a8037f5f18c43fd8ce5c750d1385e1a6c3ceaf9347bd/Cython-0.25.2-cp
-cp27m-manylinux1_x86_64.whl (6.4MB)
100% |████████████████████████████████| 6.4MB 369kB/s
Installing collected packages: Cython
Successfully installed Cython-0.25.2
再python setup.py install, 這回又有提示:
$ python setup.py install
Traceback (most recent call last):
File "setup.py", line 430, in <module>
run_setup(None)
File "setup.py", line 428, in run_setup
**kw)
File "/usr/local/lib/python2.7/distutils/core.py", line 111, in setup
_setup_distribution = dist = klass(attrs)
File "build/bdist.linux-x86_64/egg/setuptools/dist.py", line 239, in __init__
File "build/bdist.linux-x86_64/egg/setuptools/dist.py", line 263, in fetch_build_eggs
File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 580, in resolve
pkg_resources.VersionConflict: (Cython 0.25.2 (/usr/local/lib/python2.7/site-packages), Requirement.parse('Cython>=0.20,<0.25'))
暈死,這個版本還有范圍。
找了好久,發現在這個地方:setup.py Line 391:
if pre_build_check():
kw['setup_requires'] = ['Cython>=0.20,<0.25']
else:
sys.stderr.write("Bypassing Cython setup requirement\n")
直接改成0.26 試試。
之后安裝就成功了。