Exception: Versioning for this project requires either an sdist tarball,问题解决方法

本文记录了在Python2.7环境下尝试导入TensorFlow时遇到的错误,并提供了解决方案,包括升级distribute和重新安装TensorFlow_gpu的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[root@localhost ~]# python
Python 2.7.5 (default, Aug  4 2017, 00:39:18) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "/usr/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 114, in <module>
    from tensorflow.python.platform import test
  File "/usr/lib/python2.7/site-packages/tensorflow/python/platform/test.py", line 60, in <module>
    import mock                # pylint: disable=g-import-not-at-top,unused-import
  File "/usr/lib/python2.7/site-packages/mock/__init__.py", line 2, in <module>
    import mock.mock as _mock
  File "/usr/lib/python2.7/site-packages/mock/mock.py", line 71, in <module>
    _v = VersionInfo('mock').semantic_version()
  File "/usr/lib/python2.7/site-packages/pbr/version.py", line 461, in semantic_version
    self._semantic = self._get_version_from_pkg_resources()
  File "/usr/lib/python2.7/site-packages/pbr/version.py", line 448, in _get_version_from_pkg_resources
    result_string = packaging.get_version(self.package)
  File "/usr/lib/python2.7/site-packages/pbr/packaging.py", line 755, in get_version
    name=package_name))
Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. It's also pup.cfg and the argument given to pbr.version.VersionInfo. Project name mock was given, but was not able to be found.

解决方法:

sudo pip install --upgrade distribute
执行有问题使用下面方法

pip install --upgrade tensorflow_gpu




C:\Users\lgfse\Desktop\GuidedLDA-master>python setup.py install C:\Users\lgfse\AppData\Local\Programs\Python\Python312\Lib\site-packages\setuptools\dist.py:599: SetuptoolsDeprecationWarning: Invalid dash-separated key 'description-file' in 'metadata' (setup.cfg), please use the underscore name 'description_file' instead. !! ******************************************************************************** Usage of dash-separated 'description-file' will not be supported in future versions. Please use the underscore name 'description_file' instead. By 2026-Mar-03, you need to update your project and remove deprecated calls or your builds will no longer be supported. See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details. ******************************************************************************** !! opt = self._enforce_underscore(opt, section) C:\Users\lgfse\AppData\Local\Programs\Python\Python312\Lib\site-packages\setuptools\dist.py:599: SetuptoolsDeprecationWarning: Invalid dash-separated key 'author-email' in 'metadata' (setup.cfg), please use the underscore name 'author_email' instead. !! ******************************************************************************** Usage of dash-separated 'author-email' will not be supported in future versions. Please use the underscore name 'author_email' instead. By 2026-Mar-03, you need to update your project and remove deprecated calls or your builds will no longer be supported. See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details. ******************************************************************************** !! opt = self._enforce_underscore(opt, section) C:\Users\lgfse\AppData\Local\Programs\Python\Python312\Lib\site-packages\setuptools\dist.py:599: SetuptoolsDeprecationWarning: Invalid dash-separated key 'pre-hook.sdist_pre_hook' in 'sdist' (setup.cfg), please use the underscore name 'pre_hook.sdist_pre_hook' instead. !! ******************************************************************************** Usage of dash-separated 'pre-hook.sdist_pre_hook' will not be supported in future versions. Please use the underscore name 'pre_hook.sdist_pre_hook' instead. By 2026-Mar-03, you need to update your project and remove deprecated calls or your builds will no longer be supported. See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details. ******************************************************************************** !! opt = self._enforce_underscore(opt, section) C:\Users\lgfse\AppData\Local\Programs\Python\Python312\Lib\site-packages\setuptools\dist.py:759: SetuptoolsDeprecationWarning: License classifiers are deprecated. !! ******************************************************************************** Please consider removing the following classifiers in favor of a SPDX license expression: License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0) See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details. ******************************************************************************** !! self._finalize_license_expression() C:\Users\lgfse\AppData\Local\Programs\Python\Python312\Lib\site-packages\setuptools\__init__.py:92: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated. !! ******************************************************************************** Requirements should be satisfied by a PEP 517 installer. If you are using pip, you can try `pip install --use-pep517`. By 2025-Oct-31, you need to update your project and remove deprecated calls or your builds will no longer be supported. ******************************************************************************** !! dist.fetch_build_eggs(dist.setup_requires) C:\Users\lgfse\Desktop\GuidedLDA-master\.eggs\pbr-6.1.1-py3.12.egg\pbr\util.py:75: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81. import pkg_resources Error parsing Traceback (most recent call last): File "C:\Users\lgfse\Desktop\GuidedLDA-master\.eggs\pbr-6.1.1-py3.12.egg\pbr\core.py", line 105, in pbr attrs = util.cfg_to_args(path, dist.script_args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\lgfse\Desktop\GuidedLDA-master\.eggs\pbr-6.1.1-py3.12.egg\pbr\util.py", line 272, in cfg_to_args pbr.hooks.setup_hook(config) File "C:\Users\lgfse\Desktop\GuidedLDA-master\.eggs\pbr-6.1.1-py3.12.egg\pbr\hooks\__init__.py", line 25, in setup_hook metadata_config.run() File "C:\Users\lgfse\Desktop\GuidedLDA-master\.eggs\pbr-6.1.1-py3.12.egg\pbr\hooks\base.py", line 27, in run self.hook() File "C:\Users\lgfse\Desktop\GuidedLDA-master\.eggs\pbr-6.1.1-py3.12.egg\pbr\hooks\metadata.py", line 25, in hook self.config['version'] = packaging.get_version( ^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\lgfse\Desktop\GuidedLDA-master\.eggs\pbr-6.1.1-py3.12.egg\pbr\packaging.py", line 866, in get_version raise Exception("Versioning for this project requires either an sdist" Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. It's also possible that there is a mismatch between the package name in setup.cfg and the argument given to pbr.version.VersionInfo. Project name guidedlda was given, but was not able to be found. error in setup command: Error parsing C:\Users\lgfse\Desktop\GuidedLDA-master\setup.cfg: Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. It's also possible that there is a mismatch between the package name in setup.cfg and the argument given to pbr.version.VersionInfo. Project name guidedlda was given, but was not able to be found.
最新发布
07-07
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值