使用Python安装Cassandra驱动程序时出现错误

6
我正在尝试在Windows上使用Python安装cassandra-driver,但出现以下异常。有人能帮我解决吗?
我也尝试了以下位置提到的手动安装过程,但是出现了相同的错误, http://datastax.github.io/python-driver/installation.html 安装异常:
C:\Windows\System32>pip install cassandra-driver
Collecting cassandra-driver
  Using cached cassandra-driver-3.9.0.tar.gz
Requirement already satisfied: six>=1.6 in c:\python27\lib\site-packages (from c
assandra-driver)
Requirement already satisfied: futures in c:\python27\lib\site-packages (from ca
ssandra-driver)
Building wheels for collected packages: cassandra-driver
  Running setup.py bdist_wheel for cassandra-driver ... error
  Complete output from command c:\python27\python.exe -u -c "import setuptools,
tokenize;__file__='c:\\users\\user01\\appdata\\local\\temp\\pip-build-pa7rph\\
cassandra-driver\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.r
ead().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdi
st_wheel -d c:\users\user01\appdata\local\temp\tmpbqprncpip-wheel- --python-ta
g cp27:
  Unable to find pgen, not compiling formal grammar.
  warning: no files found matching '*.pyx' under directory 'Cython\Debugger\Test
s'
  warning: no files found matching '*.pxd' under directory 'Cython\Debugger\Test
s'
  warning: no files found matching '*.h' under directory 'Cython\Debugger\Tests'

  warning: no files found matching '*.pxd' under directory 'Cython\Utility'
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "c:\users\user01\appdata\local\temp\pip-build-pa7rph\cassandra-driver
\setup.py", line 433, in <module>
      run_setup(None)
    File "c:\users\user01\appdata\local\temp\pip-build-pa7rph\cassandra-driver
\setup.py", line 431, in run_setup
      **kw)
    File "c:\python27\lib\distutils\core.py", line 112, in setup
      _setup_distribution = dist = klass(attrs)
    File "c:\python27\lib\site-packages\setuptools\dist.py", line 318, in __init
__
      self.fetch_build_eggs(attrs['setup_requires'])
    File "c:\python27\lib\site-packages\setuptools\dist.py", line 373, in fetch_
build_eggs
      replace_conflicting=True,
    File "c:\python27\lib\site-packages\pkg_resources\__init__.py", line 851, in
 resolve
      dist = best[req.key] = env.best_match(req, ws, installer)
    File "c:\python27\lib\site-packages\pkg_resources\__init__.py", line 1123, i
n best_match
      return self.obtain(req, installer)
    File "c:\python27\lib\site-packages\pkg_resources\__init__.py", line 1135, i
n obtain
      return installer(requirement)
    File "c:\python27\lib\site-packages\setuptools\dist.py", line 441, in fetch_
build_egg
      return cmd.easy_install(req)
    File "c:\python27\lib\site-packages\setuptools\command\easy_install.py", lin
e 674, in easy_install
      return self.install_item(spec, dist.location, tmpdir, deps)
    File "c:\python27\lib\site-packages\setuptools\command\easy_install.py", lin
e 700, in install_item
      dists = self.install_eggs(spec, download, tmpdir)
    File "c:\python27\lib\site-packages\setuptools\command\easy_install.py", lin
e 881, in install_eggs
      return self.build_and_install(setup_script, setup_base)
    File "c:\python27\lib\site-packages\setuptools\command\easy_install.py", lin
e 1120, in build_and_install
      self.run_setup(setup_script, setup_base, args)
    File "c:\python27\lib\site-packages\setuptools\command\easy_install.py", lin
e 1108, in run_setup
      raise DistutilsError("Setup script exited with %s" % (v.args[0],))
  distutils.errors.DistutilsError: Setup script exited with error: INCLUDE envir
onment variable is empty

  ----------------------------------------
  Failed building wheel for cassandra-driver
  Running setup.py clean for cassandra-driver
  Complete output from command c:\python27\python.exe -u -c "import setuptools,
tokenize;__file__='c:\\users\\user01\\appdata\\local\\temp\\pip-build-pa7rph\\
cassandra-driver\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.r
ead().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" cle
an --all:
  Unable to find pgen, not compiling formal grammar.
  warning: no files found matching '*.pyx' under directory 'Cython\Debugger\Test
s'
  warning: no files found matching '*.pxd' under directory 'Cython\Debugger\Test
s'
  warning: no files found matching '*.h' under directory 'Cython\Debugger\Tests'

  warning: no files found matching '*.pxd' under directory 'Cython\Utility'
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "c:\users\user01\appdata\local\temp\pip-build-pa7rph\cassandra-driver
\setup.py", line 433, in <module>
      run_setup(None)
    File "c:\users\user01\appdata\local\temp\pip-build-pa7rph\cassandra-driver
\setup.py", line 431, in run_setup
      **kw)
    File "c:\python27\lib\distutils\core.py", line 112, in setup
      _setup_distribution = dist = klass(attrs)
    File "c:\python27\lib\site-packages\setuptools\dist.py", line 318, in __init
__
      self.fetch_build_eggs(attrs['setup_requires'])
    File "c:\python27\lib\site-packages\setuptools\dist.py", line 373, in fetch_
build_eggs
      replace_conflicting=True,
    File "c:\python27\lib\site-packages\pkg_resources\__init__.py", line 851, in
 resolve
      dist = best[req.key] = env.best_match(req, ws, installer)
    File "c:\python27\lib\site-packages\pkg_resources\__init__.py", line 1123, i
n best_match
      return self.obtain(req, installer)
    File "c:\python27\lib\site-packages\pkg_resources\__init__.py", line 1135, i
n obtain
      return installer(requirement)
    File "c:\python27\lib\site-packages\setuptools\dist.py", line 441, in fetch_
build_egg
      return cmd.easy_install(req)
    File "c:\python27\lib\site-packages\setuptools\command\easy_install.py", lin
e 674, in easy_install
      return self.install_item(spec, dist.location, tmpdir, deps)
    File "c:\python27\lib\site-packages\setuptools\command\easy_install.py", lin
e 700, in install_item
      dists = self.install_eggs(spec, download, tmpdir)
    File "c:\python27\lib\site-packages\setuptools\command\easy_install.py", lin
e 881, in install_eggs
      return self.build_and_install(setup_script, setup_base)
    File "c:\python27\lib\site-packages\setuptools\command\easy_install.py", lin
e 1120, in build_and_install
      self.run_setup(setup_script, setup_base, args)
    File "c:\python27\lib\site-packages\setuptools\command\easy_install.py", lin
e 1108, in run_setup
      raise DistutilsError("Setup script exited with %s" % (v.args[0],))
  distutils.errors.DistutilsError: Setup script exited with error: INCLUDE envir
onment variable is empty

  ----------------------------------------
  Failed cleaning build dir for cassandra-driver
Failed to build cassandra-driver
Installing collected packages: cassandra-driver
  Running setup.py install for cassandra-driver ... error
    Complete output from command c:\python27\python.exe -u -c "import setuptools
, tokenize;__file__='c:\\users\\user01\\appdata\\local\\temp\\pip-build-pa7rph
\\cassandra-driver\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f
.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" i
nstall --record c:\users\user01\appdata\local\temp\pip-inudnv-record\install-r
ecord.txt --single-version-externally-managed --compile:
    Unable to find pgen, not compiling formal grammar.
    warning: no files found matching '*.pyx' under directory 'Cython\Debugger\Te
sts'
    warning: no files found matching '*.pxd' under directory 'Cython\Debugger\Te
sts'
    warning: no files found matching '*.h' under directory 'Cython\Debugger\Test
s'
    warning: no files found matching '*.pxd' under directory 'Cython\Utility'
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "c:\users\user01\appdata\local\temp\pip-build-pa7rph\cassandra-driv
er\setup.py", line 433, in <module>
        run_setup(None)
      File "c:\users\user01\appdata\local\temp\pip-build-pa7rph\cassandra-driv
er\setup.py", line 431, in run_setup
        **kw)
      File "c:\python27\lib\distutils\core.py", line 112, in setup
        _setup_distribution = dist = klass(attrs)
      File "c:\python27\lib\site-packages\setuptools\dist.py", line 318, in __in
it__
        self.fetch_build_eggs(attrs['setup_requires'])
      File "c:\python27\lib\site-packages\setuptools\dist.py", line 373, in fetc
h_build_eggs
        replace_conflicting=True,
      File "c:\python27\lib\site-packages\pkg_resources\__init__.py", line 851,
in resolve
        dist = best[req.key] = env.best_match(req, ws, installer)
      File "c:\python27\lib\site-packages\pkg_resources\__init__.py", line 1123,
 in best_match
        return self.obtain(req, installer)
      File "c:\python27\lib\site-packages\pkg_resources\__init__.py", line 1135,
 in obtain
        return installer(requirement)
      File "c:\python27\lib\site-packages\setuptools\dist.py", line 441, in fetc
h_build_egg
        return cmd.easy_install(req)
      File "c:\python27\lib\site-packages\setuptools\command\easy_install.py", l
ine 674, in easy_install
        return self.install_item(spec, dist.location, tmpdir, deps)
      File "c:\python27\lib\site-packages\setuptools\command\easy_install.py", l
ine 700, in install_item
        dists = self.install_eggs(spec, download, tmpdir)
      File "c:\python27\lib\site-packages\setuptools\command\easy_install.py", l
ine 881, in install_eggs
        return self.build_and_install(setup_script, setup_base)
      File "c:\python27\lib\site-packages\setuptools\command\easy_install.py", l
ine 1120, in build_and_install
        self.run_setup(setup_script, setup_base, args)
      File "c:\python27\lib\site-packages\setuptools\command\easy_install.py", l
ine 1108, in run_setup
        raise DistutilsError("Setup script exited with %s" % (v.args[0],))
    distutils.errors.DistutilsError: Setup script exited with error: INCLUDE env
ironment variable is empty

    ----------------------------------------
Command "c:\python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\
\users\\user01\\appdata\\local\\temp\\pip-build-pa7rph\\cassandra-driver\\setu
p.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n',
'\n');f.close();exec(compile(code, __file__, 'exec'))" install --record c:\users
\user01\appdata\local\temp\pip-inudnv-record\install-record.txt --single-versi
on-externally-managed --compile" failed with error code 1 in c:\users\user01\a
ppdata\local\temp\pip-build-pa7rph\cassandra-driver\
4个回答

11

我能够成功地使用以下命令安装cassandra-driver:

命令:

pip install cassandra-driver --install-option="--no-cython"

以下是完整的安装日志(供您参考):

C:\Windows\System32>pip install cassandra-driver --install-option="--no-cython"
c:\python27\lib\site-packages\pip\commands\install.py:194: UserWarning: Disablin
g all use of wheels due to the use of --build-options / --global-options / --ins
tall-options.
  cmdoptions.check_install_build_global(options)
Collecting cassandra-driver
c:\python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\ssl_.py
:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Na
me Indication) extension to TLS is not available on this platform. This may caus
e the server to present an incorrect TLS certificate, which can cause validation
 failures. You can upgrade to a newer version of Python to solve this. For more
information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissi
ngwarning.
  SNIMissingWarning
c:\python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\ssl_.py
:122: InsecurePlatformWarning: A true SSLContext object is not available. This p
revents urllib3 from configuring SSL appropriately and may cause certain SSL con
nections to fail. You can upgrade to a newer version of Python to solve this. Fo
r more information, see https://urllib3.readthedocs.io/en/latest/security.html#i
nsecureplatformwarning.
  InsecurePlatformWarning
  Using cached cassandra-driver-3.9.0.tar.gz
Requirement already satisfied: six>=1.6 in c:\python27\lib\site-packages (from c
assandra-driver)
Requirement already satisfied: futures in c:\python27\lib\site-packages (from ca
ssandra-driver)
Skipping bdist_wheel for cassandra-driver, due to binaries being disabled for it
.
Installing collected packages: cassandra-driver
  Running setup.py install for cassandra-driver ... done
Successfully installed cassandra-driver-3.9.0

2

我使用以下命令在远程安装了cqlsh客户端:

sudo apt-get install build-essential python-dev python-pip libev4 libev-dev
sudo apt-get install cython3
sudo pip install cassandra-driver
sudo pip install cassandra-driver --install-option="--no-cython"
sudo pip install cqlsh; (Or cqlsh==5.0.3)
export CQLSH_NO_BUNDLED=TRUE
cqlsh 192.168.0.330  --cqlversion="3.4.2"

1
卡桑德拉驱动显然需要Cython。因此,pip install cython可以解决这个问题。

我成功安装了Cython,但在安装cassandra-driver时仍然遇到相同的错误。 - Siva Dasari

0

以上的方法都对我没用,因为我正在使用virtualenv。

yum install -y python-virtualenv
virtualenv-2.7 /opt/test

我所做的是:

/opt/test/bin/pip install --upgrade pip
/opt/test/bin/pip install typing cython
/opt/test/bin/pip install cassandra-driver

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接