在藍雲上使用swiftclient時的異常:在Apache Spark實例的Jupyter筆記本中,導入失敗。

2024-06-16 11:51:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在bluemix上编写python代码,它可以使用swiftclient库创建和删除容器中的文件。但是,下面的代码引发了一个异常。请注意,我使用的是apachespark上的笔记本。我可以上传这个作为一个应用程序代码一旦开发完成。 最后可以看到一个例外: 例外:此项目的版本控制需要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?***

Tags: infromimportgitselfclientstringversion
1条回答
网友
1楼 · 发布于 2024-06-16 11:51:53

我看到您正在使用“bluemix\u ipythonspark\u 16”spark服务实例,其环境可能类似本文件:你知道吗

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

我会在这里更新,如果我发现任何旧环境的解决办法。你知道吗

谢谢你, 查尔斯。你知道吗

相关问题 更多 >