Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sphinx version 4.2.0 fails on Python 3.10 #9835

Closed
Nelson-Gon opened this issue Nov 9, 2021 · 7 comments
Closed

Sphinx version 4.2.0 fails on Python 3.10 #9835

Nelson-Gon opened this issue Nov 9, 2021 · 7 comments

Comments

@Nelson-Gon
Copy link

Nelson-Gon commented Nov 9, 2021

Describe the bug

Sphinx 4.2.0 fails to build docs with Python 3.1.0.

How to Reproduce

$ git clone https://github.com/Nelson-Gon/pyfdc.git
$ cd pyfdc
# Here one should instead use the latest Sphinx not the one in requirements.txt
$ pip install -r requirements.txt
$ ./scripts/mkdocs.sh

Expected behavior

I expected to have Sphinx build docs without any error.

Your project

https://github.com/Nelson-Gon/pyfdc

Screenshots

No response

OS

Windows 10

Python version

3.10

Sphinx version

4.2.0

Sphinx extensions

No response

Extra tools

No response

Additional context

The error message is ImportError: cannot import name 'Union' from 'types'
This is marked as resolved in #9562 but the solutions there do not work for me.

@tk0miya
Copy link
Member

tk0miya commented Nov 10, 2021

Could you paste or attach a stacktrace file here?

@Nelson-Gon
Copy link
Author

This is the stack trace

Traceback (most recent call last):
  File "C:\Users\Nelg\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\Nelg\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\Nelg\AppData\Local\Programs\Python\Python310\Scripts\sphinx-build.exe\__main__.py", line 4, in <module>
  File "C:\Users\Nelg\AppData\Local\Programs\Python\Python310\lib\site-packages\sphinx\cmd\build.py", line 25, in <module>
    from sphinx.application import Sphinx
  File "C:\Users\Nelg\AppData\Local\Programs\Python\Python310\lib\site-packages\sphinx\application.py", line 31, in <module>
    from sphinx.config import Config
  File "C:\Users\Nelg\AppData\Local\Programs\Python\Python310\lib\site-packages\sphinx\config.py", line 21, in <module>
    from sphinx.util import logging
  File "C:\Users\Nelg\AppData\Local\Programs\Python\Python310\lib\site-packages\sphinx\util\__init__.py", line 41, in <module>
    from sphinx.util.typing import PathMatcher
  File "C:\Users\Nelg\AppData\Local\Programs\Python\Python310\lib\site-packages\sphinx\util\typing.py", line 37, in <module>
    from types import Union as types_Union
ImportError: cannot import name 'Union' from 'types' (C:\Users\Nelg\AppData\Local\Programs\Python\Python310\lib\types.py)

@tk0miya
Copy link
Member

tk0miya commented Nov 10, 2021

  File "C:\Users\Nelg\AppData\Local\Programs\Python\Python310\lib\site-packages\sphinx\util\typing.py", line 37, in <module>
    from types import Union as types_Union

Strange. Sphinx-4.2.0 does not contain this line.

try:
from types import UnionType # type: ignore # python 3.10 or above
except ImportError:
UnionType = None

Please check the version of Sphinx.

@Nelson-Gon
Copy link
Author

Nelson-Gon commented Nov 10, 2021

@tk0miya Thank you for your response. Here is the output from pip freeze on my system.

Sphinx==4.2.0
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5

I am not sure, I installed the stable version from PyPI directly. Maybe this is the issue?

@tk0miya
Copy link
Member

tk0miya commented Nov 10, 2021

Sorry, I'm not sure what is happened on your environment. Only I can say is that the stacktrace let us know you're using incorrect version of Sphinx. So you need to find a way to upgrade it.

@Nelson-Gon
Copy link
Author

I decided to upgrade to the dev version and instead got this message during the docs build:

Running Sphinx v4.4.0+
loading pickled environment... failed
failed: ObjectEntry.__new__() missing 1 required positional argument: 'aliased'

It seems this is not an error and instead some message?

@tk0miya
Copy link
Member

tk0miya commented Nov 11, 2021

It seems Sphinx failed to load the environment data for the incremental build. I'm not sure why it happened. But it can be recovered automatically by full-build. So you don't need to worry.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants