0

我正在 bluemix 上编写一个 python 代码,它可以使用 swiftclient 库在容器中创建和删除文件。但是,以下代码引发了异常。请注意,我在 Apache Spark 上使用 Notebook。开发完成后,我可以将其作为应用程序代码上传。最后可以看到异常:“异常:此项目的版本控制需要 sdist tarball,或访问上游 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?***
4

1 回答 1

0

我看到您正在使用“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

如果我找到旧环境的任何解决方法,我会在这里更新。

谢谢,查尔斯。

于 2016-06-07T19:05:44.757 回答