1

When running 'python setup.py develop' or 'python setup.py install' I receive the following traceback.

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'

Interestingly, if I rerun the same command as above, the installation is successful.

Just for kicks, I tried adding debugging statements to the pbr/packaging.py file both when easy_install was imported and used. It looked just fine when it was imported however, was None when accessed at line 512 as per the traceback.

Below is my requirements file that I am using:

pyyaml                                                                                                                                                                                                                                                                 
requests
termcolor
mock
nose
cached_property
argparse
unittest2
tox
stevedore
kombu

and setup.py script:

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',
)

Quick searches on Google indicate that others have encountered variations of what I am seeing however, I couldn't locate a solution to the problem.

sorin
  • 161,544
  • 178
  • 535
  • 806

2 Answers2

0

I had a very similar problem and found a workaround.

I also got AttributeError: 'NoneType' object has no attribute 'get_script_header'

Workaround that fixed it for me: In the list install_requires I had "tornado" before "luigi". By switching the order to "luigi" and then "tornado" this bug went away. I see that you do not use tornado or luigi, but I guess the ordering is still the cause of this problem since you can fix the problem by running your install command twice.

Additional note: Before finding this workaround I tried to upgrade to newest setuptools (v 5.8). It did not solve the bug.

David Wickstrom
  • 5,048
  • 1
  • 19
  • 14
0

I had the same problem and it was fixed by updating setuptools version, i.e.:

pip install --upgrade setuptools
gforcada
  • 2,498
  • 17
  • 26