Bluemix 上的 swiftclient 异常:在 Apache Spark 实例上的 Jupyter notebo



我正在 bluemix 上编写一个 python 代码,它可以使用 swiftclient 库在容器中创建和删除文件。但是,以下代码会引发异常。请注意,我在Apache Spark上使用Notebook。开发完成后,我可以将其作为应用程序代码上传。 最后可以看到异常:"例外:这个项目的版本控制需要 sdist 压缩包,或者访问上游 git 存储库。你确定安装了 git 吗?

Exception                                 Traceback (most recent call last)
<ipython-input-6-c6375c8f3026> in <module>()
     13   'tenantId':'sdb2-2605e7ecec4bce-07c8d52a704f'
     14 }
---> 15 import swiftclient.client
     16 from keystoneclient import client
     17 
/gpfs/fs01/user/sdb2-2605e7ecec4bce-07c8d52a704f/.local/lib/python2.7/site-packages/swiftclient/__init__.py in <module>()
     18 OpenStack Swift Python client binding.
     19 """
---> 20 from .client import *  # noqa
     21 
     22 # At setup.py time, we haven't installed anything yet, so there
/gpfs/fs01/user/sdb2-2605e7ecec4bce-07c8d52a704f/.local/lib/python2.7/site-packages/swiftclient/client.py in <module>()
     30 import six
     31 
---> 32 from swiftclient import version as swiftclient_version
     33 from swiftclient.exceptions import ClientException
     34 from swiftclient.utils import (
/gpfs/fs01/user/sdb2-2605e7ecec4bce-07c8d52a704f/.local/lib/python2.7/site-packages/swiftclient/version.py in <module>()
     26     # its thing to figure out a version number.
     27     import pbr.version
---> 28     version_string = str(pbr.version.VersionInfo('python-swiftclient'))
/usr/local/src/bluemix_ipythonspark_16/notebook/lib/python2.7/site-packages/pbr-0.11.0-py2.7.egg/pbr/version.pyc in __str__(self)
    414     def __str__(self):
    415         """Make the VersionInfo object behave like a string."""
--> 416         return self.version_string()
    417 
    418     def __repr__(self):
/usr/local/src/bluemix_ipythonspark_16/notebook/lib/python2.7/site-packages/pbr-0.11.0-py2.7.egg/pbr/version.pyc in version_string(self)
    455     def version_string(self):
    456         """Return the short version minus any alpha/beta tags."""
--> 457         return self.semantic_version().brief_string()
    458 
    459     # Compatibility functions
/usr/local/src/bluemix_ipythonspark_16/notebook/lib/python2.7/site-packages/pbr-0.11.0-py2.7.egg/pbr/version.pyc in semantic_version(self)
    450         """Return the SemanticVersion object for this version."""
    451         if self._semantic is None:
--> 452             self._semantic = self._get_version_from_pkg_resources()
    453         return self._semantic
    454 
/usr/local/src/bluemix_ipythonspark_16/notebook/lib/python2.7/site-packages/pbr-0.11.0-py2.7.egg/pbr/version.pyc in _get_version_from_pkg_resources(self)
    437             # installed into anything. Revert to setup-time logic.
    438             from pbr import packaging
--> 439             result_string = packaging.get_version(self.package)
    440         return SemanticVersion.from_pip_string(result_string)
    441 
/usr/local/src/bluemix_ipythonspark_16/notebook/lib/python2.7/site-packages/pbr-0.11.0-py2.7.egg/pbr/packaging.pyc in get_version(package_name, pre_version)
    658     if version:
    659         return version
--> 660     raise Exception("Versioning for this project requires either an sdist"
    661                     " tarball, or access to an upstream git repository."
    662                     " Are you sure that git is installed?")
***Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. Are you sure that git is installed?***

我看到您正在使用"bluemix_ipythonspark_16"火花服务实例,其环境可能如下所示:-

Language
Python 2.7
Notebook (Jupyter)
IPython 3.2.1
Spark as a Service
Apache Spark 1.6

我可以在这种环境中重现您的问题,但我认为它可能与 IPython 环境有关。这似乎是具有IPython的旧Spark服务实例的问题。

您将在 bluemix 上创建的任何新 Spark 服务都将具有 Jupyter 环境。

Language
Python 2.7
Notebook (Jupyter)
Jupyter 4.0.6
Spark as a Service
Apache Spark 1.6

我对此进行了测试,并且在这个新环境中不会发生该问题。如果可能的话,试一试

https://github.com/charles2588/bluemixsparknotebooks/raw/master/Python/SO_swiftclient_version.ipynb

如果我找到适用于旧环境的任何解决方法,我将在此处更新。

谢谢查尔斯。

相关内容

最新更新