Search code examples
pythonheroku

Not able to install a library in Heroku


I am new to Heroku. I tried installing the library logging by specifying in the requirements.txt file and even using the web console, both times it returned with this error:

ERROR: Command errored out with exit status 1:
     command: /app/.heroku/python/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-_pd86m9k/logging/setup.py'"'"'; __file__='"'"'/tmp/pip-install-_pd86m9k/logging/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-zn83hw3w
         cwd: /tmp/pip-install-_pd86m9k/logging/
    Complete output (48 lines):
    running egg_info
    creating /tmp/pip-pip-egg-info-zn83hw3w/logging.egg-info
    writing /tmp/pip-pip-egg-info-zn83hw3w/logging.egg-info/PKG-INFO
    writing dependency_links to /tmp/pip-pip-egg-info-zn83hw3w/logging.egg-info/dependency_links.txt
    writing top-level names to /tmp/pip-pip-egg-info-zn83hw3w/logging.egg-info/top_level.txt
    writing manifest file '/tmp/pip-pip-egg-info-zn83hw3w/logging.egg-info/SOURCES.txt'
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-_pd86m9k/logging/setup.py", line 3, in <module>
        setup(name = "logging",
      File "/app/.heroku/python/lib/python3.8/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/app/.heroku/python/lib/python3.8/distutils/dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "/app/.heroku/python/lib/python3.8/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/app/.heroku/python/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 297, in run
        self.find_sources()
      File "/app/.heroku/python/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 304, in find_sources
        mm.run()
      File "/app/.heroku/python/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 535, in run
        self.add_defaults()
      File "/app/.heroku/python/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 571, in add_defaults
        sdist.add_defaults(self)
      File "/app/.heroku/python/lib/python3.8/distutils/command/sdist.py", line 226, in add_defaults
        self._add_defaults_python()
      File "/app/.heroku/python/lib/python3.8/site-packages/setuptools/command/sdist.py", line 135, in _add_defaults_python
        build_py = self.get_finalized_command('build_py')
      File "/app/.heroku/python/lib/python3.8/distutils/cmd.py", line 298, in get_finalized_command
        cmd_obj = self.distribution.get_command_obj(command, create)
      File "/app/.heroku/python/lib/python3.8/distutils/dist.py", line 857, in get_command_obj
        klass = self.get_command_class(command)
      File "/app/.heroku/python/lib/python3.8/site-packages/setuptools/dist.py", line 764, in get_command_class
        self.cmdclass[command] = cmdclass = ep.load()
      File "/app/.heroku/python/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2462, in load
        return self.resolve()
      File "/app/.heroku/python/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2468, in resolve
        module = __import__(self.module_name, fromlist=['__name__'], level=0)
      File "/app/.heroku/python/lib/python3.8/site-packages/setuptools/command/build_py.py", line 16, in <module>
        from setuptools.lib2to3_ex import Mixin2to3
      File "/app/.heroku/python/lib/python3.8/site-packages/setuptools/lib2to3_ex.py", line 13, in <module>
        from lib2to3.refactor import RefactoringTool, get_fixers_from_package
      File "/app/.heroku/python/lib/python3.8/lib2to3/refactor.py", line 19, in <module>
        import logging
      File "/tmp/pip-install-_pd86m9k/logging/logging/__init__.py", line 618
        raise NotImplementedError, 'emit must be implemented '\
                                 ^
    SyntaxError: invalid syntax

Any idea where am I going wrong or what I should do?


Solution

  • The logging module on PyPI is ancient, having been most recently updated in June, 2013. The specific error you're seeing is due to the old tuple syntax for except which was removed in Python 3.0.

    You are probably just looking for the logging module that has been included with Python since version 2.3. Since it is part of the standard library you don't need to do anything to install it.

    Remove it from your requirements.txt, commit, and redeploy.