Search code examples
pythonheroku

How can I fix Heroku error: "Command errored out with exit status 1"?


I want to host my Discord Bot on Heroku for free. I tried building it but I get an error while hosting the bot, that I can't solve.

This is the activity log of Discord Bot while publishing it into Heroku:

Building on the Heroku-20 stack

Using buildpack: Heroku/python

Python app detected

No Python version was specified. Using the same version as the last build: python-3.9.5

To use a different version, see: https://devcenter.heroku.com/articles/python-runtimes

Requirements file has been changed, clearing cached dependencies

Installing python-3.9.5

Installing pip 20.2.4, setuptools 47.1.1 and wheel 0.36.2

Installing SQLite3

Installing requirements with pip


   Collecting setuptools==49.6.0

     Downloading setuptools-49.6.0-py3-none-any.whl (803 kB)

   Collecting discord.py==1.7.2

     Downloading discord.py-1.7.2-py3-none-any.whl (786 kB)

   Collecting discord

     Downloading discord-1.0.1-py3-none-any.whl (1.1 kB)

   Collecting dotenv

     Downloading dotenv-0.0.5.tar.gz (2.4 kB)

       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-06xhzdfv/dotenv/setup.py'"'"'; __file__='"'"'/tmp/pip-install-06xhzdfv/dotenv/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-m_r1ttd_

            cwd: /tmp/pip-install-06xhzdfv/dotenv/

       Complete output (51 lines):

           ERROR: Command errored out with exit status 1:

            command: /app/.heroku/python/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-wheel-9yg4cjho/distribute/setup.py'"'"'; __file__='"'"'/tmp/pip-wheel-9yg4cjho/distribute/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-3dj58cd9

                cwd: /tmp/pip-wheel-9yg4cjho/distribute/

           Complete output (15 lines):

           Traceback (most recent call last):

             File "<string>", line 1, in <module>

             File "/tmp/pip-wheel-9yg4cjho/distribute/setuptools/__init__.py", line 2, in <module>

               from setuptools.extension import Extension, Library

             File "/tmp/pip-wheel-9yg4cjho/distribute/setuptools/extension.py", line 5, in <module>

               from setuptools.dist import _get_unpatched

             File "/tmp/pip-wheel-9yg4cjho/distribute/setuptools/dist.py", line 7, in <module>

               from setuptools.command.install import install

             File "/tmp/pip-wheel-9yg4cjho/distribute/setuptools/command/__init__.py", line 8, in <module>

               from setuptools.command import install_scripts

             File "/tmp/pip-wheel-9yg4cjho/distribute/setuptools/command/install_scripts.py", line 3, in <module>

               from pkg_resources import Distribution, PathMetadata, ensure_directory

             File "/tmp/pip-wheel-9yg4cjho/distribute/pkg_resources.py", line 1518, in <module>

               register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)

           AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'

           ----------------------------------------

       ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

       Traceback (most recent call last):

         File "/app/.heroku/python/lib/python3.9/site-packages/setuptools/installer.py", line 128, in fetch_build_egg

           subprocess.check_call(cmd)

         File "/app/.heroku/python/lib/python3.9/subprocess.py", line 373, in check_call

           raise CalledProcessError(retcode, cmd)

       subprocess.CalledProcessError: Command '['/app/.heroku/python/bin/python', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmp6e4wiu5n', '--quiet', 'distribute']' returned non-zero exit status 1.

       

       During handling of the above exception, another exception occurred:

       

       Traceback (most recent call last):

         File "<string>", line 1, in <module>

         File "/tmp/pip-install-06xhzdfv/dotenv/setup.py", line 13, in <module>

           setup(name='dotenv',

         File "/app/.heroku/python/lib/python3.9/site-packages/setuptools/__init__.py", line 160, in setup

           _install_setup_requires(attrs)

         File "/app/.heroku/python/lib/python3.9/site-packages/setuptools/__init__.py", line 155, in _install_setup_requires

           dist.fetch_build_eggs(dist.setup_requires)

         File "/app/.heroku/python/lib/python3.9/site-packages/setuptools/dist.py", line 695, in fetch_build_eggs

           resolved_dists = pkg_resources.working_set.resolve(

         File "/app/.heroku/python/lib/python3.9/site-packages/pkg_resources/__init__.py", line 781, in resolve

           dist = best[req.key] = env.best_match(

         File "/app/.heroku/python/lib/python3.9/site-packages/pkg_resources/__init__.py", line 1066, in best_match

           return self.obtain(req, installer)

         File "/app/.heroku/python/lib/python3.9/site-packages/pkg_resources/__init__.py", line 1078, in obtain

           return installer(requirement)

         File "/app/.heroku/python/lib/python3.9/site-packages/setuptools/dist.py", line 754, in fetch_build_egg

           return fetch_build_egg(self, req)

         File "/app/.heroku/python/lib/python3.9/site-packages/setuptools/installer.py", line 130, in fetch_build_egg

           raise DistutilsError(str(e))

       distutils.errors.DistutilsError: Command '['/app/.heroku/python/bin/python', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmp6e4wiu5n', '--quiet', 'distribute']' returned non-zero exit status 1.

       ----------------------------------------

   ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

! Push rejected, failed to compile Python app.

! Push failed


Solution

  • You are installing the wrong package. Change dotenv to python-dotenv in your requirements.txt file. See this issue for more information. https://github.com/theskumar/python-dotenv/issues/113