Mypy: Fails to install on Python 3.9 on Windows

Created on 25 Sep 2020  路  7Comments  路  Source: python/mypy

Bug Report

MyPy fails to install on Python 3.9.

To Reproduce

(Write your steps here:)

  1. Install Python 3.9
  2. pip install mypy
  3. Observe error installing

Expected Behavior

Package installs normally as on previous python versions.

Actual Behavior

An exception occurs when installing due to typed-ast dependency which explicitly does not support Python 3.9 (see readme). Example output below:

Collecting mypy
  Using cached mypy-0.782-py3-none-any.whl (2.4 MB)
Collecting typed-ast<1.5.0,>=1.4.0
  Using cached typed_ast-1.4.1.tar.gz (208 kB)
Requirement already satisfied: typing-extensions>=3.7.4 in y:\git\game\venv\lib\site-packages (from mypy) (3.7.4.3)
Requirement already satisfied: mypy-extensions<0.5.0,>=0.4.3 in y:\git\game\venv\lib\site-packages (from mypy) (0.4.3)
Using legacy 'setup.py install' for typed-ast, since package 'wheel' is not installed.
Installing collected packages: typed-ast, mypy
    Running setup.py install for typed-ast ... error
    ERROR: Command errored out with exit status 1:
     command: 'y:\git\game\venv\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\tech\\AppData\\Local\\Temp\\pip-install-xo
mc8b46\\typed-ast\\setup.py'"'"'; __file__='"'"'C:\\Users\\tech\\AppData\\Local\\Temp\\pip-install-xomc8b46\\typed-ast\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"
'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\tech\App
Data\Local\Temp\pip-record-26ilfbh2\install-record.txt' --single-version-externally-managed --compile --install-headers 'y:\git\game\venv\include\site\python3.9\type
d-ast'
         cwd: C:\Users\tech\AppData\Local\Temp\pip-install-xomc8b46\typed-ast\
    Complete output (25 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.9
    creating build\lib.win-amd64-3.9\typed_ast
    copying typed_ast\ast27.py -> build\lib.win-amd64-3.9\typed_ast
    copying typed_ast\ast3.py -> build\lib.win-amd64-3.9\typed_ast
    copying typed_ast\conversions.py -> build\lib.win-amd64-3.9\typed_ast
    copying typed_ast\__init__.py -> build\lib.win-amd64-3.9\typed_ast
    package init file 'ast3\tests\__init__.py' not found (or not a regular file)
    creating build\lib.win-amd64-3.9\typed_ast\tests
    copying ast3\tests\test_basics.py -> build\lib.win-amd64-3.9\typed_ast\tests
    running build_ext
    building '_ast27' extension
    creating build\temp.win-amd64-3.9
    creating build\temp.win-amd64-3.9\Release
    creating build\temp.win-amd64-3.9\Release\ast27
    creating build\temp.win-amd64-3.9\Release\ast27\Custom
    creating build\temp.win-amd64-3.9\Release\ast27\Parser
    creating build\temp.win-amd64-3.9\Release\ast27\Python
    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Iast27/Includ
e -Iy:\git\game\venv\include -IC:\Python\3.9\include -IC:\Python\3.9\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.2831
4\include /Tcast27/Custom/typed_ast.c /Fobuild\temp.win-amd64-3.9\Release\ast27/Custom/typed_ast.obj
    typed_ast.c
    C:\Python\3.9\include\pyconfig.h(59): fatal error C1083: Cannot open include file: 'io.h': No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.24.28314\\bin\\HostX86\\x64\\cl.exe' failed with exit code
 2
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'y:\git\game\venv\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\tech\\App
Data\\Local\\Temp\\pip-install-xomc8b46\\typed-ast\\setup.py'"'"'; __file__='"'"'C:\\Users\\tech\\AppData\\Local\\Temp\\pip-install-xomc8b46\\typed-ast\\setup.py'"'"
';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' in
stall --record 'C:\Users\tech\AppData\Local\Temp\pip-record-26ilfbh2\install-record.txt' --single-version-externally-managed --compile --install-headers 'y:\git\game
\venv\include\site\python3.9\typed-ast' Check the logs for full command output.

Your Environment

  • Mypy version used: N/A
  • Mypy command-line flags: N/A
  • Mypy configuration options from mypy.ini (and other config files): N/A
  • Python version used: 3.9.0rc2
  • Operating system and version:
    Win 10 Pro
    Version 1909 (OS Build 18363.1016)
  • pip: 20.2.1
  • setuptools: 49.2.1
priority-0-high

Most helpful comment

I think in order to create those wheels we'd have to configure Travis and AppVeyor to add 3.9. I'll give it a try.

All 7 comments

Assuming this is specific to Windows -- cannot repro on Mac.

Yeah, it's Windows specific. I assume it's similar to https://github.com/python/typed_ast/issues/126

@hauntsaninja This is the same issue. I originally raised the issue in typed_ast but I closed it after I read that they explicitly do not support Python 3.9.

Hm, typed-ast is still needed to parse Python 2.7. So if possible we should raise that on the typed-ast project. It may require copying a bunch of C code, IIRC 3.9 makes more internal APIs actually invisible.

(In the meantime I guess the workaround is to use Python 3.8 to run mypy over Python 2.7 source code. But I agree that鈥檚 awkward.)

I think we might just need to upload a working wheel for Windows (it actually looks like we don't have a wheel for Linux either, https://pypi.org/project/typed-ast/#files). Is this something you could do? I see that you made the last typed_ast release.

At some point, maybe we should consider making Python 2 support an extra, so that the typed_ast dependency is optional.

I think in order to create those wheels we'd have to configure Travis and AppVeyor to add 3.9. I'll give it a try.

Was this page helpful?
0 / 5 - 0 ratings