Frage

I am having some trouble installing PyInstaller. Whenever I try and run setup.py with python setup.py install, it gives me this error:

Traceback (most recent call last):
  File "setup.py", line 18, in <module>
   from PyInstaller import get_version
ImportError: cannot import name get_version

setup.py:

Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.4
Classifier: Programming Language :: Python :: 2.5
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 2 :: Only
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Build Tools
Classifier: Topic :: System :: Installation/Setup
Classifier: Topic :: System :: Software Distribution
Classifier: Topic :: Utilities
""".splitlines()

# Make the distribution files to always report the git-revision used
# then building the distribution packages. This is done by replacing
# PyInstaller/utils/git.py within the dist/build by a fake-module
# which always returns the current git-revision. The original
# source-file is unchanged.
#
# This has to be done in 'build_py' for bdist-commands and in 'sdist'
# for sdist-commands.

def _write_git_version_file(filename):
    """
    Fake PyInstaller.utils.git.py to always return the current revision.
    """
    git_version = PyInstaller.utils.git.get_repo_revision()
    st = os.stat(filename)
    # remove the file first for the case it's hard-linked to the
    # original file
    os.remove(filename)
    git_mod = open(filename, 'w')
    template = "def get_repo_revision(): return %r"
    try:
        git_mod.write(template % git_version)
    finally:
        git_mod.close()
    os.chmod(filename, stat.S_IMODE(st.st_mode))


class my_build_py(build_py):
    def build_module(self, module, module_file, package):
        res = build_py.build_module(self, module, module_file, package)
        if module == 'git' and package == 'PyInstaller.utils':
            filename = self.get_module_outfile(
                self.build_lib, package.split('.'), module)
            _write_git_version_file(filename)
        return res


class my_sdist(sdist):
    def make_release_tree(self, base_dir, files):
        res = sdist.make_release_tree(self, base_dir, files)
        build_py = self.get_finalized_command('build_py')
        filename = build_py.get_module_outfile(
            base_dir, ['PyInstaller', 'utils'], 'git')
        _write_git_version_file(filename)
        return res

setup(
    install_requires=['distribute'],

    name='PyInstaller',
    version=get_version(),

    description=DESC,
    long_description=LONG_DESC,
    keywords='packaging, standalone executable, pyinstaller, macholib, freeze, py2exe, py2app, bbfreeze',

    author='Giovanni Bajo, Hartmut Goebel, Martin Zibricky',
    author_email='pyinstaller@googlegroups.com',
    maintainer='Giovanni Bajo, Hartmut Goebel, Martin Zibricky',
    maintainer_email='pyinstaller@googlegroups.com',

    license=('GPL license with a special exception which allows to use '
             'PyInstaller to build and distribute non-free programs '
             '(including commercial ones)'),
    url='http://www.pyinstaller.org',
    download_url='https://sourceforge.net/projects/pyinstaller/files',

    classifiers=CLASSIFIERS,
    zip_safe=False,
    packages=find_packages(),
    package_data={
        # This includes precompiled bootloaders.
        'PyInstaller': ['bootloader/*/*'],
        # This file is necessary for rthooks (runtime hooks).
        'PyInstaller.loader': ['rthooks.dat'],
        },
    include_package_data=True,
    cmdclass = {
        'sdist': my_sdist,
        'build_py': my_build_py,
        },

    entry_points="""
    [console_scripts]
    pyinstaller=PyInstaller.main:run
    pyi-archive_viewer=PyInstaller.cliutils.archive_viewer:run
    pyi-bindepend=PyInstaller.cliutils.bindepend:run
    pyi-build=PyInstaller.cliutils.build:run
    pyi-grab_version=PyInstaller.cliutils.grab_version:run
    pyi-make_comserver=PyInstaller.cliutils.make_comserver:run
    pyi-makespec=PyInstaller.cliutils.makespec:run
    pyi-set_version=PyInstaller.cliutils.set_version:run
    """
)
War es hilfreich?

Lösung

Try looking at these two sources:

http://pythonhosted.org/PyInstaller/

http://www.pythoncentral.io/pyinstaller-package-python-applications-windows-mac-linux/

These may help you find a solution to your problem.

Andere Tipps

I think I figured out what is wrong. I don't have pywin32 installed.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top