首页 > 解决方案 > LookupError: setuptools-scm 无法检测版本(使用 python setup.py install 时)

问题描述

我正在尝试在python虚拟环境3.7(名为“py37”)中安装setup.py(来自网站:https ://github.com/richpsharp/ipbes-analysis/tree/1.1.0/ipbes-ndr) .

我输入:

  1. git 克隆https://github.com/richpsharp/ipbes-analysis.git
  2. cd ipbes-分析\ipbes-ndr
  3. python setup.py 安装

但是,我得到了错误:

C:\Users\86134>activate py37
(py37) C:\Users\86134>cd ipbes-analysis\ipbes-ndr
(py37) C:\Users\86134\ipbes-analysis\ipbes-ndr>python setup.py install
Traceback (most recent call last):
  File "setup.py", line 26, in <module>
    language="c++",
  File "F:\Anaconda3\envs\py37\lib\site-packages\setuptools\__init__.py", line 153, in setup
    return distutils.core.setup(**attrs)
  File "F:\Anaconda3\envs\py37\lib\distutils\core.py", line 108, in setup
    _setup_distribution = dist = klass(attrs)
  File "F:\Anaconda3\envs\py37\lib\site-packages\setuptools\dist.py", line 433, in __init__
    k: v for k, v in attrs.items()
  File "F:\Anaconda3\envs\py37\lib\distutils\dist.py", line 292, in __init__
    self.finalize_options()
  File "F:\Anaconda3\envs\py37\lib\site-packages\setuptools\dist.py", line 708, in finalize_options
    ep(self)
  File "F:\Anaconda3\envs\py37\lib\site-packages\setuptools\dist.py", line 715, in _finalize_setup_keywords
    ep.load()(self, ep.name, value)
  File "F:\Anaconda3\envs\py37\lib\site-packages\setuptools_scm\integration.py", line 26, in version_keyword
    dist.metadata.version = _get_version(config)
  File "F:\Anaconda3\envs\py37\lib\site-packages\setuptools_scm\__init__.py", line 173, in _get_version
    parsed_version = _do_parse(config)
  File "F:\Anaconda3\envs\py37\lib\site-packages\setuptools_scm\__init__.py", line 142, in _do_parse
    "use git+https://github.com/user/proj.git#egg=proj" % config.absolute_root
LookupError: setuptools-scm was unable to detect version for 'C:\\Users\\86134\\ipbes-analysis\\ipbes-ndr'.

Make sure you're either building from a fully intact git repository or PyPI tarballs. Most other sources (such as GitHub's tarballs, a git checkout without the .git folder) don't contain the necessary metadata and will not work.

For example, if you're using pip, instead of https://github.com/user/proj/archive/master.zip use git+https://github.com/user/proj.git#egg=proj

setup.py的内容是:

"""setup.py module for ipbes_ndr_analysis module."""
from Cython.Build import cythonize
import numpy
from setuptools.extension import Extension
from setuptools import setup

setup(
    name='ipbes ndr analysis',
    packages=[
        'ipbes_ndr_analysis',
    ],
    package_dir={
        'ipbes_ndr_analysis': 'src/ipbes_ndr_analysis'
    },

    use_scm_version={
        'version_scheme': 'post-release',
        'local_scheme': 'node-and-date'},
    setup_requires=['setuptools_scm', 'cython', 'numpy'],
    include_package_data=True,
    ext_modules=cythonize(
        [Extension(
            "ipbes_ndr_analysis_cython",
            sources=["src/ipbes_ndr_analysis/ipbes_ndr_analysis_cython.pyx"],
            include_dirs=[numpy.get_include()],
            language="c++",
        )],
        )
)

我不确定如何解决此错误...任何帮助将不胜感激。谢谢!!

玉琪

标签: pythonsetuptoolssetup.pysetuptools-scm

解决方案


推荐阅读