2016-01-18 59 views
3

幾個月前,我使用了docker文件(1)使用base ubuntu映像,(2)安裝miniconda python發行版,(3)使用miniconda安裝一些python庫,(4)運行以下命令爲python設置cassandra驅動程序。在Docker中設置cassandra驅動程序(python)

RUN pip install --upgrade pip 
RUN pip install cassandra-driver 

這在六個月前就完美了。但現在我得到這個例外。

Step 13 : RUN pip install cassandra-driver 
---> Running in ba9955650d7c 
Collecting cassandra-driver 
    Downloading cassandra-driver-3.0.0.tar.gz (186kB) 
    Complete output from command python setup.py egg_info: 
    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' 
    unable to execute 'gcc': No such file or directory 
    Unable to find pgen, not compiling formal grammar. 
    Traceback (most recent call last): 
     File "<string>", line 20, in <module> 
     File "/tmp/pip-build-0XzsPv/cassandra-driver/setup.py", line 375, in <module> 
     run_setup(None) 
     File "/tmp/pip-build-0XzsPv/cassandra-driver/setup.py", line 373, in run_setup 
     **kw) 
     File "/miniconda/lib/python2.7/distutils/core.py", line 111, in setup 
     _setup_distribution = dist = klass(attrs) 
     File "/miniconda/lib/python2.7/site-packages/setuptools-19.1.1-py2.7.egg/setuptools/dist.py", line 268, in __init__ 
     File "/miniconda/lib/python2.7/site-packages/setuptools-19.1.1-py2.7.egg/setuptools/dist.py", line 312, in fetch_build_eggs 
     File "/miniconda/lib/python2.7/site-packages/setuptools-19.1.1-py2.7.egg/pkg_resources/__init__.py", line 846, in resolve 
     File "/miniconda/lib/python2.7/site-packages/setuptools-19.1.1-py2.7.egg/pkg_resources/__init__.py", line 1091, in best_match 
     File "/miniconda/lib/python2.7/site-packages/setuptools-19.1.1-py2.7.egg/pkg_resources/__init__.py", line 1103, in obtain 
     File "/miniconda/lib/python2.7/site-packages/setuptools-19.1.1-py2.7.egg/setuptools/dist.py", line 379, in fetch_build_egg 
     File "/miniconda/lib/python2.7/site-packages/setuptools-19.1.1-py2.7.egg/setuptools/command/easy_install.py", line 639, in easy_install 
     File "/miniconda/lib/python2.7/site-packages/setuptools-19.1.1-py2.7.egg/setuptools/command/easy_install.py", line 669, in install_item 
     File "/miniconda/lib/python2.7/site-packages/setuptools-19.1.1-py2.7.egg/setuptools/command/easy_install.py", line 852, in install_eggs 
     File "/miniconda/lib/python2.7/site-packages/setuptools-19.1.1-py2.7.egg/setuptools/command/easy_install.py", line 1080, in build_and_install 
     File "/miniconda/lib/python2.7/site-packages/setuptools-19.1.1-py2.7.egg/setuptools/command/easy_install.py", line 1068, in run_setup 
    distutils.errors.DistutilsError: Setup script exited with error: command 'gcc' failed with exit status 1 

    ---------------------------------------- 
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-0XzsPv/cassandra-driver 
The command '/bin/sh -c pip install cassandra-driver' returned a non-zero code: 1 

什麼可能會出錯?安裝包是否損壞或者我沒有正確執行?

回答

5

蟒蛇卡桑德拉驅動程序現在默認使用Cython擴展since version 2.7.0,但有一個逃生孵化這些瓦特ho無法輕鬆訪問cython發行版或者不需要它,這對您來說可能是一個不錯的選擇。 cython擴展爲性能提供了一個好處,但它可能不適用於很多情況(特別是在你沒有做高吞吐量的情況下)。

install documentation

默認情況下,這個包使用用Cython優化核心模塊和構建自定義擴展。這不是一個很難的要求,但默認情況下,它構建的擴展提供了比純Python實現更好的性能。

此生成相可以使用構建開關,或環境變量來避免:

python setup.py install --no-cython 
-or- 
pip install --install-option="--no-cython" <spec-or-path> 

可替代地,環境變量可以用於無論切換上下文的此選項:

CASS_DRIVER_NO_CYTHON=1 <your script here> 
+1

這是現在正確的解決方法。我還打開了一張票來改善默認行爲:https://datastax-oss.atlassian.net/browse/PYTHON-471 –

3

爲了安裝cassandra-driver你需要編譯一些C源文件,但是你沒有gcc您的容器內的更多信息:

unable to execute 'gcc': No such file or directory 

嘗試安裝cassandra-driver之前安裝gccpython-dev包:

RUN apt-get update \ 
    && apt-get install -y --no-install-recommends \ 
    python-dev \ 
    gcc \ 
    && rm -rf /var/lib/apt/lists/* 
+0

是的工作。謝謝。 – Aditya

相關問題