简体   繁体   English

如何修复setuptools / wheel.py:157 _convert_metadata中的“无此文件或目录”错误

[英]How to fix “No such file or directory” error in setuptools/wheel.py:157 _convert_metadata

When running python setup.py test, python setup.py build, or even python setup.py --help-commands I get an "OSError: [Errno 2] No such file or directory". 当运行python setup.py测试,python setup.py build甚至python setup.py --help-commands时,我得到一个“ OSError:[Errno 2] No such file or directory”。

So far I've tried upgrading setuptools (currently running version 41.0.1) but this hasn't resolved the issue. 到目前为止,我已经尝试升级setuptools(当前正在运行版本41.0.1),但这尚未解决问题。

My anonymised setup.py looks like: 我匿名的setup.py看起来像:

from setuptools import setup, find_packages


def read_version():
    with open('version') as ver:
        return ver.read().strip()


config = {
    'description': 'package',
    'author': 'Me',
    'author_email': 'email@email.com',
    'version': read_version(),
    'packages': find_packages(),
    'package_data': {
        'manager.resources': ['*.yaml'],
    },
    'scripts': [],
    'name': 'company.packagename',
    'namespace_packages': ['company'],
    'test_suite': 'tests',
    'entry_points': {
        'console_scripts': [
            'launcher = manager_launcher:main',
            'managerschemas = manager.validation:export',
            'managertypes = manager.types:export',
        ]
    },
    'setup_requires': ['pytest-runner'],
    'tests_require': [
        'flake8',
        'pylint',
        'pytest',
        'pytest-cov',
        'pytest-mock',
    ],
}

if __name__ == '__main__':
    setup(**config)

and setup.cfg is: 和setup.cfg是:

[aliases]
test = pytest

[flake8]
max-line-length = 120
exclude = venv,.eggs

[tool:pytest]
addopts = -vvvv --cov=manager --cov-branch --cov-fail-under=100 --cov-report=term --cov-report=html --junitxml=junit.xml
testpaths = tests

The traceback I'm getting is: 我得到的追溯是:

Traceback (most recent call last):
  File "setup.py", line 40, in <module>
    setup(**config)
  File "/home/vagrant/.local/lib/python2.7/site-packages/setuptools/__init__.py", line 144, in setup
    _install_setup_requires(attrs)
  File "/home/vagrant/.local/lib/python2.7/site-packages/setuptools/__init__.py", line 139, in _install_setup_requires
    dist.fetch_build_eggs(dist.setup_requires)
  File "/home/vagrant/.local/lib/python2.7/site-packages/setuptools/dist.py", line 717, in fetch_build_eggs
    replace_conflicting=True,
  File "/home/vagrant/.local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 782, in resolve
    replace_conflicting=replace_conflicting
  File "/home/vagrant/.local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1065, in best_match
    return self.obtain(req, installer)
  File "/home/vagrant/.local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1077, in obtain
    return installer(requirement)
  File "/home/vagrant/.local/lib/python2.7/site-packages/setuptools/dist.py", line 784, in fetch_build_egg
    return cmd.easy_install(req)
  File "/home/vagrant/.local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 679, in easy_install
    return self.install_item(spec, dist.location, tmpdir, deps)
  File "/home/vagrant/.local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 705, in install_item
    dists = self.install_eggs(spec, download, tmpdir)
  File "/home/vagrant/.local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 855, in install_eggs
    return [self.install_wheel(dist_filename, tmpdir)]
  File "/home/vagrant/.local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1073, in install_wheel
    os.path.dirname(destination)
  File "/usr/lib/python2.7/distutils/cmd.py", line 349, in execute
    util.execute(func, args, msg, dry_run=self.dry_run)
  File "/usr/lib/python2.7/distutils/util.py", line 309, in execute
    func(*args)
  File "/home/vagrant/.local/lib/python2.7/site-packages/setuptools/wheel.py", line 101, in install_as_egg
    self._install_as_egg(destination_eggdir, zf)
  File "/home/vagrant/.local/lib/python2.7/site-packages/setuptools/wheel.py", line 109, in _install_as_egg
    self._convert_metadata(zf, destination_eggdir, dist_info, egg_info)
  File "/home/vagrant/.local/lib/python2.7/site-packages/setuptools/wheel.py", line 157, in _convert_metadata
    os.path.join(egg_info, 'PKG-INFO'),
OSError: [Errno 2] No such file or directory

So it turns out that this problem was being caused by lag in Vagrant/Virtualbox's synced folders. 因此事实证明,此问题是由Vagrant / Virtualbox同步文件夹中的延迟引起的。 I was trying to build the Python project inside a Vagrant VM shared from the host file system using a synced folder. 我试图在Vagrant VM中构建Python项目,该VM使用同步文件夹与主机文件系统共享。 Copying the project out of the synced folder into another folder in the VM allows it to build. 将项目从同步文件夹中复制到VM中的另一个文件夹中,即可进行构建。 Another dirty hack that worked was to add a time.sleep(1) in the setuptools/wheel.py source file on line 157 before the os.rename that was causing the OS Exception to be raised. 另一个有效的方法是在第157行的setup.tools/wheel.py源文件中添加time.sleep(1),然后再引发引起OS异常的os.rename。 This gives the file system a chance to sync, and therefore works around the issue. 这使文件系统有机会进行同步,因此可以解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我该如何修复脚本标头的过早结尾以及没有此类文件或目录:&#39;./。py&#39;的exec错误 - How do i fix Premature end of script headers and No such file or directory: exec of './.py' error setuptools pip 轮失败,错误代码为 2 - setuptools pip wheel failed with error code 2 如何修复 poershell(py 文件)上的错误 - How can fix that error on poershell (py file) 如何使用setuptools和setup.py从包中排除单个文件 - How to exclude a single file from package with setuptools and setup.py Setuptools pip wheel失败,错误代码为2(Pycharm) - Setuptools pip wheel failed with error code 2 (Pycharm) 如何解决MacOS for python 3.9的“Preparing wheel metadata ... error”这个错误 - How to solve "Preparing wheel metadata ... error" this error for MacOS for python 3.9 如何解决此“无文件或目录”错误 - How do I fix this 'No file or directory' error 使 setuptools 与 one_file.py 一起工作的最小目录结构是什么? - What's the minimal directory structure to make setuptools work with one_file.py? Pip 错误生成元数据设置工具不可用 - Pip error generating metadata setuptools not available 如何将 Python.pyd 文件转换为 Windows 上的轮子? - How to convert a Python .pyd file to a wheel on Windows?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM