sphinx-contrib / matlabdomain

A Sphinx extension for documenting Matlab code
http://sphinxcontrib-matlabdomain.readthedocs.io/
Other
70 stars 45 forks source link

Cannot import safe_repr #39

Closed joeced closed 6 years ago

joeced commented 9 years ago

Originally reported by: Anonymous


I am using sphinx to generate code for a matlab document, however I cannot build anything due to an error on the beginning of build;

Could not import extension sphinxcontrib.matlab (exception: cannot import name safe_repr) make: *** [html] Error 1

I am unsure why this error is appearing as the call seems valid in the extension.


joeced commented 6 years ago

Original comment by Mark Mikofski (Bitbucket: bwanamarko, GitHub: Unknown):


fixes #34

joeced commented 9 years ago

Original comment by Mark Mikofski (Bitbucket: bwanamarko, GitHub: Unknown):


fixes #34

joeced commented 9 years ago

Original comment by yarmond (Bitbucket: yarmond, GitHub: yarmond):


I think the following would work with both Sphinx 1.2.x and 1.3.x:

#!python

try:
    # Sphinx >= 1.3.0
    from sphinx.util.inspect import object_description
except ImportError:
    # Sphinx < 1.3.0
    from sphinx.util.inspect import safe_repr as object_description
joeced commented 9 years ago

Original comment by Mark Mikofski (Bitbucket: bwanamarko, GitHub: Unknown):


joeced commented 9 years ago

Original comment by Mark Mikofski (Bitbucket: bwanamarko, GitHub: Unknown):


joeced commented 9 years ago

Original comment by Vincent Lostanlen (Bitbucket: lostanlen, GitHub: lostanlen):


Hi, I have the same problem on Sphinx v1.3.1, Python 2.7.6 and OS X 10.10.2. The call trace is essentially the same.

joeced commented 9 years ago

Original comment by Levyn (Bitbucket: Levyn, GitHub: Levyn):


I just got the same error with python v2.7.9 and sphinx v1.3.1 on Windows 7

Originally I tried to use sphinxcontrib-matlabdomain with python v3.4 (WinPython). But there I got errors that looked like being syntax problems, so I changed to python v2. Would it actually be possible to run sphinxcontrib-matlabdomain with python v3? I did not find this information in the extension's description.

Below some further information about the errors of the python v2 attempt:

Thanks in advance, Levyn


Here's my conf.py

#!python

import sys
import os

sys.path.insert(0, os.path.abspath('..\..\sphinxcontrib-matlabdomain-0.2.6\sphinxcontrib'))
sys.path.insert(0, os.path.abspath('..\..\sphinxcontrib-matlabdomain-0.2.6'))

extensions = [
    'sphinx.ext.autodoc',
    'sphinx.ext.viewcode',
    'sphinxcontrib.matlab',
]

templates_path = ['_templates']
source_suffix = '.rst'
master_doc = 'index'
project = 'TestMAtlab'
copyright = '2015, Levyn'
version = '1'
release = '1'
exclude_patterns = []
pygments_style = 'sphinx'
html_theme = 'default'
html_static_path = ['_static']
htmlhelp_basename = 'TestMAtlabdoc'
latex_elements = {
latex_documents = [
  ('index', 'TestMAtlab.tex', 'TestMAtlab Documentation',
   'Levyn', 'manual'),
]
man_pages = [
    ('index', 'testmatlab', 'TestMAtlab Documentation',
     ['Levyn'], 1)
]
texinfo_documents = [
  ('index', 'TestMAtlab', 'TestMAtlab Documentation',
   'Levyn', 'TestMAtlab', 'One line description of project.',
   'Miscellaneous'),
]

and here's the error message from the cmd:

#!cmd

C:\Users\Levyn\Documents\7_Sphinx\TestMatlab>sphinx-build -vvv -P -b html source build
Running Sphinx v1.3.1
[app] setting up extension: 'sphinx.ext.autodoc'
[app] adding autodocumenter: <class 'sphinx.ext.autodoc.ModuleDocumenter'>
[app] adding directive: ('automodule', <class 'sphinx.ext.autodoc.AutoDirective'>, None, None, {})
[app] adding autodocumenter: <class 'sphinx.ext.autodoc.ClassDocumenter'>
[app] adding directive: ('autoclass', <class 'sphinx.ext.autodoc.AutoDirective'>, None, None, {})
[app] adding autodocumenter: <class 'sphinx.ext.autodoc.ExceptionDocumenter'>
[app] adding directive: ('autoexception', <class 'sphinx.ext.autodoc.AutoDirective'>, None, None, {})
[app] adding autodocumenter: <class 'sphinx.ext.autodoc.DataDocumenter'>
[app] adding directive: ('autodata', <class 'sphinx.ext.autodoc.AutoDirective'>, None, None, {})
[app] adding autodocumenter: <class 'sphinx.ext.autodoc.FunctionDocumenter'>
[app] adding directive: ('autofunction', <class 'sphinx.ext.autodoc.AutoDirective'>, None, None, {})
[app] adding autodocumenter: <class 'sphinx.ext.autodoc.MethodDocumenter'>
[app] adding directive: ('automethod', <class 'sphinx.ext.autodoc.AutoDirective'>, None, None, {})
[app] adding autodocumenter: <class 'sphinx.ext.autodoc.AttributeDocumenter'>
[app] adding directive: ('autoattribute', <class 'sphinx.ext.autodoc.AutoDirective'>, None, None, {})
[app] adding autodocumenter: <class 'sphinx.ext.autodoc.InstanceAttributeDocumenter'>
[app] adding directive: ('autoinstanceattribute', <class 'sphinx.ext.autodoc.AutoDirective'>, None, None, {})
[app] adding config value: ('autoclass_content', 'class', True)
[app] adding config value: ('autodoc_member_order', 'alphabetic', True)
[app] adding config value: ('autodoc_default_flags', [], True)
[app] adding config value: ('autodoc_docstring_signature', True, True)
[app] adding config value: ('autodoc_mock_imports', [], True)
[app] adding event: 'autodoc-process-docstring'
[app] adding event: 'autodoc-process-signature'
[app] adding event: 'autodoc-skip-member'
[app] setting up extension: 'sphinx.ext.viewcode'
[app] adding config value: ('viewcode_import', True, False)
[app] connecting event 'doctree-read': <function doctree_read at 0x03379CF0> [id=0]
[app] connecting event 'env-merge-info': <function env_merge_info at 0x03379D30> [id=1]
[app] connecting event 'html-collect-pages': <function collect_pages at 0x03379DB0> [id=2]
[app] connecting event 'missing-reference': <function missing_reference at 0x03379D70> [id=3]
[app] setting up extension: 'sphinxcontrib.matlab'
Original exception:
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\sphinx-1.3.1-py2.7.egg\sphinx\application.py", line 429, in setup_extension
    mod = __import__(extension, None, None, ['setup'])
  File "C:\Python27\lib\site-packages\sphinxcontrib_matlabdomain-0.2.6-py2.7.egg\sphinxcontrib\matlab.py", line 13, in <module>
    import mat_documenters as doc
  File "C:\Python27\lib\site-packages\sphinxcontrib_matlabdomain-0.2.6-py2.7.egg\sphinxcontrib\mat_documenters.py", line 28, in <module>
    from sphinx.util.inspect import getargspec, isdescriptor, safe_getmembers, \
ImportError: cannot import name safe_repr

Exception occurred while building, starting debugger:
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\sphinx-1.3.1-py2.7.egg\sphinx\cmdline.py", line 244, in main
    opts.warningiserror, opts.tags, opts.verbosity, opts.jobs)
  File "C:\Python27\lib\site-packages\sphinx-1.3.1-py2.7.egg\sphinx\application.py", line 143, in __init__
    self.setup_extension(extension)
  File "C:\Python27\lib\site-packages\sphinx-1.3.1-py2.7.egg\sphinx\application.py", line 433, in setup_extension
    err)
ExtensionError: Could not import extension sphinxcontrib.matlab (exception: cannot import name safe_repr)
> c:\python27\lib\site-packages\sphinx-1.3.1-py2.7.egg\sphinx\application.py(433)setup_extension()
-> err)
joeced commented 9 years ago

Original comment by Mark Mikofski (Bitbucket: bwanamarko, GitHub: Unknown):


@Aeus, could you please provide more detail:

I've never seen this error, so without more to go on, I'm not sure what to look for.