48

The Heroku Build is returning this error when I'm trying to deploy a Django application for the past few days. The Django Code and File Structure are the same as Django's Official Documentation and Procfile is added in the root folder.

Log -

-----> Building on the Heroku-20 stack
-----> Determining which buildpack to use for this app
-----> Python app detected
-----> No Python version was specified. Using the buildpack default: python-3.10.4
       To use a different version, see: https://devcenter.heroku.com/articles/python-runtimes
       Building wheels for collected packages: backports.zoneinfo
         Building wheel for backports.zoneinfo (pyproject.toml): started
         Building wheel for backports.zoneinfo (pyproject.toml): finished with status 'error'
         ERROR: Command errored out with exit status 1:
          command: /app/.heroku/python/bin/python /app/.heroku/python/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py build_wheel /tmp/tmpqqu_1qow
              cwd: /tmp/pip-install-txfn1ua9/backports-zoneinfo_a462ef61051d49e7bf54e715f78a34f1
         Complete output (41 lines):
         running bdist_wheel
         running build
         running build_py
         creating build
         creating build/lib.linux-x86_64-3.10
         creating build/lib.linux-x86_64-3.10/backports
         copying src/backports/__init__.py -> build/lib.linux-x86_64-3.10/backports
         creating build/lib.linux-x86_64-3.10/backports/zoneinfo
         copying src/backports/zoneinfo/_zoneinfo.py -> build/lib.linux-x86_64-3.10/backports/zoneinfo
         copying src/backports/zoneinfo/_tzpath.py -> build/lib.linux-x86_64-3.10/backports/zoneinfo
         copying src/backports/zoneinfo/_common.py -> build/lib.linux-x86_64-3.10/backports/zoneinfo
         copying src/backports/zoneinfo/_version.py -> build/lib.linux-x86_64-3.10/backports/zoneinfo
         copying src/backports/zoneinfo/__init__.py -> build/lib.linux-x86_64-3.10/backports/zoneinfo
         running egg_info
         writing src/backports.zoneinfo.egg-info/PKG-INFO
         writing dependency_links to src/backports.zoneinfo.egg-info/dependency_links.txt
         writing requirements to src/backports.zoneinfo.egg-info/requires.txt
         writing top-level names to src/backports.zoneinfo.egg-info/top_level.txt
         reading manifest file 'src/backports.zoneinfo.egg-info/SOURCES.txt'
         reading manifest template 'MANIFEST.in'
         warning: no files found matching '*.png' under directory 'docs'
         warning: no files found matching '*.svg' under directory 'docs'
         no previously-included directories found matching 'docs/_build'
         no previously-included directories found matching 'docs/_output'
         adding license file 'LICENSE'
         adding license file 'licenses/LICENSE_APACHE'
         writing manifest file 'src/backports.zoneinfo.egg-info/SOURCES.txt'
         copying src/backports/zoneinfo/__init__.pyi -> build/lib.linux-x86_64-3.10/backports/zoneinfo
         copying src/backports/zoneinfo/py.typed -> build/lib.linux-x86_64-3.10/backports/zoneinfo
         running build_ext
         building 'backports.zoneinfo._czoneinfo' extension
         creating build/temp.linux-x86_64-3.10
         creating build/temp.linux-x86_64-3.10/lib
         gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/app/.heroku/python/include/python3.10 -c lib/zoneinfo_module.c -o build/temp.linux-x86_64-3.10/lib/zoneinfo_module.o -std=c99
         lib/zoneinfo_module.c: In function ‘zoneinfo_fromutc’:
         lib/zoneinfo_module.c:600:19: error: ‘_PyLong_One’ undeclared (first use in this function); did you mean ‘_PyLong_New’?
           600 |             one = _PyLong_One;
               |                   ^~~~~~~~~~~
               |                   _PyLong_New
         lib/zoneinfo_module.c:600:19: note: each undeclared identifier is reported only once for each function it appears in
         error: command '/usr/bin/gcc' failed with exit code 1
         ----------------------------------------
         ERROR: Failed building wheel for backports.zoneinfo
       Failed to build backports.zoneinfo
       ERROR: Could not build wheels for backports.zoneinfo, which is required to install pyproject.toml-based projects
 !     Push rejected, failed to compile Python app.
 !     Push failed

Thanks.

SarveshJoshi
  • 580
  • 1
  • 4
  • 6
  • You need to make you're not using the SQLite database in the settings.py script. It must be changed – Conor Jul 04 '22 at 10:17

10 Answers10

94

Avoid installing backports.zoneinfo when using python >= 3.9

Edit your requirements.txt file

FROM:

backports.zoneinfo==0.2.1

TO:

backports.zoneinfo;python_version<"3.9"

OR:

backports.zoneinfo==0.2.1;python_version<"3.9"

You can read more about this here and here

ayandebnath
  • 1,055
  • 7
  • 6
  • For me backports.zoneinfo==0.2.1;python_version<"3.9" this worked – King Alawaka Apr 11 '23 at 11:16
  • If you compile your requirements, you can put this into your `requirements.in` files too, the condition will be passed on to the compiled `.piip` (or `.txt`) file. – smido Apr 25 '23 at 11:25
42

I was having the same error while deploying my application on heroku and well the problem is actually that when you are deploying it on heroku so heroku by default uses python version 3.10.x and backports.zoneinfo is not working properly with this version so I suggest you to switch to version 3.8.x(stable).

In order to do that you need to tell heroku to switch that version and it can be done as follows :

  1. Create runtime.txt in root directory.
  2. python-3.8.10 <- write this in 'runtime.txt' there as to specify the version.
  3. heroku will then install this version and you will be not getting anymore error.

PS : worked it for me and later when heroku removes this bug you can switch to python latest version.

  • 1
    This works! Just don't forget to add runtime.txt to your repo. The heroku doc on this is here: https://devcenter.heroku.com/articles/python-runtimes – Ryan Shirley Jun 02 '22 at 04:04
8

I was facing the same error while creating my container. I solved the error by using the exact version of my Python venv i.e. 3.8.9

Earlier for the image, I was using 3.8-alpine for a lighter version of the image. But, it wasn't working out for me and got the same error as yours.

DharmanBot
  • 1,066
  • 2
  • 6
  • 10
3

this type of problems occur when you forget to modify your requirements.txt file and heroku server uses default settings like it uses python updated version which is not stable. use the following commands and you will be get rid of this type of problem.

$ git status

you need to modify requirements.txt

$ git add-A

$ git commit -m "Python VERSION-3.8.10"

then push your server and i am sure you will be get rid of this type of problem. In order to push your server...

$ git push heroku master
3

Downgrading Python from 3.10.5 to 3.9.0 worked for me. I hope this helps.

Yalchin Mammadli
  • 444
  • 4
  • 11
  • This question is about deploying to Heroku, where Python 3.9.0 is not currently supported on any stack. – Dr. Red Aug 31 '22 at 19:16
1

I was facing the same error while deploying my Scrapy spider onto Heroku but using python-3.9.15 in runtime.txt resolved the issue. however, the python installed in my venv was 3.8.13

you can try one of these I don't know their actual meaning but these are recommended by Heroku you can read the full documentation here

Supported runtimes
python-3.10.8 on all supported stacks (recommended)
python-3.9.15 on all supported stacks
python-3.8.15 on Heroku-18 and Heroku-20 only
python-3.7.15 on Heroku-18 and Heroku-20 only
1

Tried & tested on Mac pro:

Check your python version on your terminal

python3 --version

OR

python --version

If the python version is 3.9 & above , then update the following (backports.zoneinfo) line in your "requirements.txt" file to :

  • backports.zoneinfo;python_version<"3.9"

Run -

pip3 install -r requirements.txt

test running your app again , should work at this stage.

Vikas Pandey
  • 197
  • 7
1

for MAC users:

export C_INCLUDE_PATH=/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/Headers

only this helped me. source is here

Artem Chege
  • 189
  • 2
  • 5
0

Install venv with python3.9 version helped for me.

python3.9 default version in my system

python3.9 -m venv venv
0

If you are in CentOS, you might be missing one of the Python development libraries that are required to build backports.zoneinfo. You can try

sudo yum install python3-devel

To install them