Search code examples
pythonvisual-c++pipcondapython-wheel

Failed building wheel for backports-zoneinfo


EDIT

I tried clearing my pip cache due to the error line Using cached backports.zoneinfo-0.2.1.tar.gz (74 kB) (maybe the cached version is broken/old and incompatible with other packages) - but this made no difference other than removing that line

CONTEXT

I've been having dependency issues after installing Python 3.9 (discussed here and here). The issues in the linked posts have been fixed, but I am uninstalling and re-installing my pip-installed packages to make sure they are compatible with my new python version. One of the packages I am trying to do this with is backports-zoneinfo. I am aware I don't really need this, but I was going to keep it anyway in case I write something needing compatibility with older python versions.

ISSUE:

I have uninstalled backports-zoneinfo, and then tried to reinstall it, but get the error message at the bottom of this post. I then installed build tools 2022 as per the error message and tried to re-install backports-zoneinfo again, but got the same error. Please can someone help me to diagnose and fix the issue?

Uninstall message:

C:\Users\u03132tk>pip uninstall backports-zoneinfo
WARNING: Ignoring invalid distribution -umpy (c:\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -umexpr (c:\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -iopython (c:\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -illow (c:\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -cipy (c:\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -umpy (c:\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -umexpr (c:\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -iopython (c:\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -illow (c:\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -cipy (c:\anaconda3\lib\site-packages)
Found existing installation: backports.zoneinfo 0.2.1
Uninstalling backports.zoneinfo-0.2.1:
  Would remove:
    c:\anaconda3\lib\site-packages\backports.zoneinfo-0.2.1.dist-info\*
    c:\anaconda3\lib\site-packages\backports\*
  Would not remove (might be manually added):
    c:\anaconda3\lib\site-packages\backports\functools_lru_cache.py
    c:\anaconda3\lib\site-packages\backports\tempfile.py
    c:\anaconda3\lib\site-packages\backports\weakref.py
Proceed (Y/n)? Y
  Successfully uninstalled backports.zoneinfo-0.2.1

Reinstall error

C:\Users\u03132tk>pip install backports-zoneinfo
WARNING: Ignoring invalid distribution -umpy (c:\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -umexpr (c:\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -iopython (c:\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -illow (c:\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -cipy (c:\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -umpy (c:\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -umexpr (c:\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -iopython (c:\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -illow (c:\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -cipy (c:\anaconda3\lib\site-packages)
Collecting backports-zoneinfo
  Using cached backports.zoneinfo-0.2.1.tar.gz (74 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: backports-zoneinfo
  Building wheel for backports-zoneinfo (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for backports-zoneinfo (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [46 lines of output]
      C:\Users\u03132tk\AppData\Local\Temp\pip-build-env-0o6uoggk\overlay\Lib\site-packages\setuptools\config\setupcfg.py:293: _DeprecatedConfig: Deprecated config in `setup.cfg`
      !!

              ********************************************************************************
              The license_file parameter is deprecated, use license_files instead.

              By 2023-Oct-30, you need to update your project and remove deprecated calls
              or your builds will no longer be supported.

              See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details.
              ********************************************************************************

      !!
        parsed = self.parsers.get(option_name, lambda x: x)(value)
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-cpython-39
      creating build\lib.win-amd64-cpython-39\backports
      copying src\backports\__init__.py -> build\lib.win-amd64-cpython-39\backports
      creating build\lib.win-amd64-cpython-39\backports\zoneinfo
      copying src\backports\zoneinfo\_common.py -> build\lib.win-amd64-cpython-39\backports\zoneinfo
      copying src\backports\zoneinfo\_tzpath.py -> build\lib.win-amd64-cpython-39\backports\zoneinfo
      copying src\backports\zoneinfo\_version.py -> build\lib.win-amd64-cpython-39\backports\zoneinfo
      copying src\backports\zoneinfo\_zoneinfo.py -> build\lib.win-amd64-cpython-39\backports\zoneinfo
      copying src\backports\zoneinfo\__init__.py -> build\lib.win-amd64-cpython-39\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.win-amd64-cpython-39\backports\zoneinfo
      copying src\backports\zoneinfo\py.typed -> build\lib.win-amd64-cpython-39\backports\zoneinfo
      running build_ext
      building 'backports.zoneinfo._czoneinfo' extension
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  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
WARNING: Ignoring invalid distribution -umpy (c:\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -umexpr (c:\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -iopython (c:\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -illow (c:\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -cipy (c:\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -umpy (c:\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -umexpr (c:\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -iopython (c:\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -illow (c:\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -cipy (c:\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -umpy (c:\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -umexpr (c:\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -iopython (c:\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -illow (c:\anaconda3\lib\site-packages)
WARNING: Ignoring invalid distribution -cipy (c:\anaconda3\lib\site-packages)

Solution

  • To actually fix this specific error, you would need a working compiler on your windows machine:

    Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/

    For that you would need to follow the link, download and install the build tools and try again.

    this particular pip package does not have a whl file for python3.9 and at the same time has a source distribution that has parts written in C/C++. Therefore pip now needs to call a compiler to build the source distribution for your machine.

    To avoid this, you have a few options though:

    1. Instead of pip, you could try installing the same package using conda install -c conda-forge backports.zoneinfo
    2. Since zoneinfo has become part of the stdlib, you can also try replacing your import backports.zoneinfo to import zoneinfo. With this method, you would need no further installation.