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

ImportError: cannot import name 'build_main' #66

Open
super-sk opened this issue Sep 16, 2019 · 10 comments
Open

ImportError: cannot import name 'build_main' #66

super-sk opened this issue Sep 16, 2019 · 10 comments

Comments

@super-sk
Copy link

Using :

  • sphinx-2.2.0
  • sphinxcontrib-versioning-2.2.1

While running any sphinxcontrib-versioning command, I got :

$ sphinx-versioning build --help

...
File "~/.virtualenvs/docs-temp/lib/python3.6/site-packages/sphinxcontrib/versioning/sphinx_.py", line 9, in <module>
    from sphinx import application, build_main, locale
ImportError: cannot import name 'build_main'

It seems like a wrong module call because build_main is not in sphinx package but it can be called from module sphinx.cmd.build.

Indeed, when I manually modify as below :

# versioning/sphinx_.py

from sphinx import build_main              # old line
from sphinx.cmd.build import build_main    # new line

everything seems to go well.

@z00sts
Copy link

z00sts commented Oct 7, 2019

Fixed here #69

But it seems CI-process is kind of broken.

@super-sk
Copy link
Author

The workaround is working, changing from sphinx import build_main to from sphinx.cmd.build import build_main. Should I close the issue right now ?

@z00sts
Copy link

z00sts commented Oct 18, 2019

@super-sk I don't think so. My PR is still on code review stage, there are some issues with CI-process. Its will be better to keep issue opened

@gryphon2411
Copy link

Any progress on this one?

@z00sts
Copy link

z00sts commented Dec 17, 2019

@Eido95 waiting for merge here #78

@Sachin-Suresh
Copy link

is anyone still facing this issue in 2022? I am getting the same error.

@basejumpa
Copy link

basejumpa commented Sep 13, 2022

Same issue here. I could need the fix as well

$ sphinx-build --version
sphinx-build 5.1.1


$ sphinx-versioning --version
Traceback (most recent call last):
  File "C:\Users\manna\scoop\apps\python\current\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\manna\scoop\apps\python\current\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\manna\scoop\apps\python\current\Scripts\sphinx-versioning.exe\__main__.py", line 4, in <module>
  File "C:\Users\manna\scoop\apps\python\current\lib\site-packages\sphinxcontrib\versioning\__main__.py", line 13, in <module>
    from sphinxcontrib.versioning.routines import build_all, gather_git_info, pre_build, read_local_conf
  File "C:\Users\manna\scoop\apps\python\current\lib\site-packages\sphinxcontrib\versioning\routines.py", line 11, in <module>
    from sphinxcontrib.versioning.sphinx_ import build, read_config
  File "C:\Users\manna\scoop\apps\python\current\lib\site-packages\sphinxcontrib\versioning\sphinx_.py", line 9, in <module>
    from sphinx import application, build_main, locale
ImportError: cannot import name 'build_main' from 'sphinx' (C:\Users\manna\scoop\apps\python\current\lib\site-packages\sphinx\__init__.py)

For the time being I'll be using https://pypi.org/project/sphinx-multiversion/

@NikosAlexandris
Copy link

Same issue here with

❯ sphinx-build --version
sphinx-build 5.0.2

and

❯ sphinx-versioning --version
Traceback (most recent call last):
  File "/home/nik/.local/bin/sphinx-versioning", line 5, in <module>
    from sphinxcontrib.versioning.__main__ import cli
  File "/home/nik/.local/lib/python3.10/site-packages/sphinxcontrib/versioning/__main__.py", line 13, in <module>
    from sphinxcontrib.versioning.routines import build_all, gather_git_info, pre_build, read_local_conf
  File "/home/nik/.local/lib/python3.10/site-packages/sphinxcontrib/versioning/routines.py", line 11, in <module>
    from sphinxcontrib.versioning.sphinx_ import build, read_config
  File "/home/nik/.local/lib/python3.10/site-packages/sphinxcontrib/versioning/sphinx_.py", line 9, in <module>
    from sphinx import application, build_main, locale
ImportError: cannot import name 'build_main' from 'sphinx' (/home/nik/.local/lib/python3.10/site-packages/sphinx/__init__.py)

@waltsims
Copy link

same issue here:

$ sphinx-build --version
sphinx-build 5.3.0

@adam-grant-hendry
Copy link

Same issue here:

OS: Windows 10
python: 3.8.10
sphinx: 6.2.1
sphinxcontrib-versioning: 2.2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants