1

运行“python setup.py develop”或“python setup.py install”时,我收到以下回溯。

Traceback (most recent call last):
  File "setup.py", line 38, in <module>
    test_suite='nose.collector',
  File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/local/home/kassan1/venvs/some_env/local/lib/python2.7/site-packages/setuptools/command/develop.py", line 27, in run
    self.install_for_development()
  File "/local/home/kassan1/venvs/some_env/local/lib/python2.7/site-packages/setuptools/command/develop.py", line 129, in install_for_development
    self.process_distribution(None, self.dist, not self.no_deps)
  File "/local/home/kassan1/venvs/some_env/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 682, in process_distribution
    [requirement], self.local_index, self.easy_install
  File "/local/home/kassan1/venvs/some_env/local/lib/python2.7/site-packages/pkg_resources.py", line 631, in resolve
    dist = best[req.key] = env.best_match(req, ws, installer)
  File "/local/home/kassan1/venvs/some_env/local/lib/python2.7/site-packages/pkg_resources.py", line 871, in best_match
    return self.obtain(req, installer)
  File "/local/home/kassan1/venvs/some_env/local/lib/python2.7/site-packages/pkg_resources.py", line 883, in obtain
    return installer(requirement)
  File "/local/home/kassan1/venvs/some_env/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 595, in easy_install
    return self.install_item(spec, dist.location, tmpdir, deps)
  File "/local/home/kassan1/venvs/some_env/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 627, in install_item
    self.process_distribution(spec, dist, deps)
  File "/local/home/kassan1/venvs/some_env/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 659, in process_distribution
    self.install_egg_scripts(dist)
  File "/local/home/kassan1/venvs/some_env/local/lib/python2.7/site-packages/setuptools/command/develop.py", line 152, in install_egg_scripts
    return easy_install.install_egg_scripts(self,dist)
  File "/local/home/kassan1/venvs/some_env/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 532, in install_egg_scripts
    self.install_wrapper_scripts(dist)
  File "/local/home/kassan1/venvs/some_env/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 734, in install_wrapper_scripts
    for args in get_script_args(dist):
  File "/local/home/kassan1/venvs/some_env/local/lib/python2.7/site-packages/pbr/packaging.py", line 512, in override_get_script_args
    header = easy_install.get_script_header("", executable, is_wininst)
AttributeError: 'NoneType' object has no attribute 'get_script_header'

有趣的是,如果我重新运行与上面相同的命令,则安装成功。

只是为了好玩,我尝试在导入和使用 easy_install 时将调试语句添加到 pbr/packaging.py 文件中。导入时它看起来很好,但是根据回溯在第 512 行访问时为 None 。

以下是我正在使用的需求文件:

pyyaml                                                                                                                                                                                                                                                                 
requests
termcolor
mock
nose
cached_property
argparse
unittest2
tox
stevedore
kombu

和 setup.py 脚本:

import ez_setup                                                                                                                                                                                                                                                        
ez_setup.use_setuptools('3.6')

import os

from setuptools import setup, find_packages

try:
    # workaround for http://bugs.python.org/issue15881
    import multiprocessing  # noqa
except ImportError:
    pass


def read(fname):
    return open(os.path.join(os.path.dirname(__file__), fname)).read()


def requirements():
    return read('requirements.txt').splitlines()


setup(
    name='MY_PROJECT',
    version='0.0.1',
    author="Noorez Kassam",
    long_description=read('README.rst'),
    install_requires=requirements(),
    entry_points={
        'console_scripts': [
            'myproj = myproj.myproj:main',
        ],
        'myproj.urloperations.download': [
            'file = myproj.filedownload:download'
        ],
    },  
    packages=find_packages(),
    test_suite='nose.collector',
)

谷歌上的快速搜索表明其他人遇到了我所看到的变化,但是我找不到问题的解决方案。

4

2 回答 2

0

我有同样的问题,它是通过更新版本修复的setuptools,即:

pip install --upgrade setuptools
于 2014-12-02T00:10:28.213 回答
0

我有一个非常相似的问题并找到了解决方法。

我也得到了AttributeError: 'NoneType' object has no attribute 'get_script_header'

为我修复它的解决方法:在列表 install_requires 中,我在“luigi”之前有“tornado”。通过将顺序切换到“luigi”然后“龙卷风”这个错误就消失了。我看到你没有使用 tornado 或 luigi,但我猜排序仍然是这个问题的原因,因为你可以通过运行你的 install 命令两次来解决这个问题。

附加说明:在找到此解决方法之前,我尝试升级到最新的 setuptools (v 5.8)。它没有解决错误。

于 2014-09-23T14:25:17.927 回答