Sphinx: Autodoc ImportError - django
I'm trying to auto generate the documentation for my Django project. The doctree gets generated on the html page but there is no documentation for any of the members within any of my modules. I keep running into this problem:
Running Sphinx v1.1.3
loading pickled environment... not yet created
building [html]: targets for 2 source files that are out of date
updating environment: 2 added, 0 changed, 0 removed
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/sphinx/ext/autodoc.py", line 321, in import_object
__import__(self.modname)
File "/home/tim/Desktop/fqdn/mysite/tool/admin.py", line 1, in <module>
from tool.models import All_alerts
File "/home/tim/Desktop/fqdn/mysite/tool/models.py", line 3, in <module>
from django.db import models
ImportError: No module named django.db
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/sphinx/ext/autodoc.py", line 321, in import_object
__import__(self.modname)
File "/home/tim/Desktop/fqdn/mysite/tool/forms.py", line 1, in <module>
from django import forms
ImportError: No module named django
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/sphinx/ext/autodoc.py", line 321, in import_object
__import__(self.modname)
File "/home/tim/Desktop/fqdn/mysite/tool/models.py", line 3, in <module>
from django.db import models
ImportError: No module named django.db
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/sphinx/ext/autodoc.py", line 321, in import_object
__import__(self.modname)
File "/home/tim/Desktop/fqdn/mysite/tool/page1urls.py", line 1, in <module>
from django.conf.urls import patterns, url, include
ImportError: No module named django.conf.urls
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/sphinx/ext/autodoc.py", line 321, in import_object
__import__(self.modname)
File "/home/tim/Desktop/fqdn/mysite/tool/page2urls.py", line 1, in <module>
from django.conf.urls import patterns, url, include
ImportError: No module named django.conf.urls
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/sphinx/ext/autodoc.py", line 321, in import_object
__import__(self.modname)
File "/home/tim/Desktop/fqdn/mysite/tool/page3urls.py", line 1, in <module>
from django.conf.urls import patterns, url, include
ImportError: No module named django.conf.urls
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/sphinx/ext/autodoc.py", line 321, in import_object
__import__(self.modname)
File "/home/tim/Desktop/fqdn/mysite/tool/page4urls.py", line 1, in <module>
from django.conf.urls import patterns, url, include
ImportError: No module named django.conf.urls
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/sphinx/ext/autodoc.py", line 321, in import_object
__import__(self.modname)
File "/home/tim/Desktop/fqdn/mysite/tool/tests.py", line 1, in <module>
from django.test import TestCase
ImportError: No module named django.test
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/sphinx/ext/autodoc.py", line 321, in import_object
__import__(self.modname)
File "/home/tim/Desktop/fqdn/mysite/tool/urls.py", line 1, in <module>
from django.conf.urls import patterns, url, include
ImportError: No module named django.conf.urls
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/sphinx/ext/autodoc.py", line 321, in import_object
__import__(self.modname)
File "/home/tim/Desktop/fqdn/mysite/tool/views.py", line 1, in <module>
from tool.models import Product
File "/home/tim/Desktop/fqdn/mysite/tool/models.py", line 3, in <module>
from django.db import models
ImportError: No module named django.db
/home/tim/Desktop/fqdn/mysite/docs/tool.rst:7: WARNING: autodoc can't import/find module 'tool.admin', it reported error: "No module named django.db", please check your spelling and sys.path
/home/tim/Desktop/fqdn/mysite/docs/tool.rst:15: WARNING: autodoc can't import/find module 'tool.forms', it reported error: "No module named django", please check your spelling and sys.path
/home/tim/Desktop/fqdn/mysite/docs/tool.rst:23: WARNING: autodoc can't import/find module 'tool.models', it reported error: "No module named django.db", please check your spelling and sys.path
/home/tim/Desktop/fqdn/mysite/docs/tool.rst:31: WARNING: autodoc can't import/find module 'tool.page1urls', it reported error: "No module named django.conf.urls", please check your spelling and sys.path
/home/tim/Desktop/fqdn/mysite/docs/tool.rst:39: WARNING: autodoc can't import/find module 'tool.page2urls', it reported error: "No module named django.conf.urls", please check your spelling and sys.path
/home/tim/Desktop/fqdn/mysite/docs/tool.rst:47: WARNING: autodoc can't import/find module 'tool.page3urls', it reported error: "No module named django.conf.urls", please check your spelling and sys.path
/home/tim/Desktop/fqdn/mysite/docs/tool.rst:55: WARNING: autodoc can't import/find module 'tool.page4urls', it reported error: "No module named django.conf.urls", please check your spelling and sys.path
/home/tim/Desktop/fqdn/mysite/docs/tool.rst:63: WARNING: autodoc can't import/find module 'tool.tests', it reported error: "No module named django.test", please check your spelling and sys.path
/home/tim/Desktop/fqdn/mysite/docs/tool.rst:71: WARNING: autodoc can't import/find module 'tool.urls', it reported error: "No module named django.conf.urls", please check your spelling and sys.path
/home/tim/Desktop/fqdn/mysite/docs/tool.rst:79: WARNING: autodoc can't import/find module 'tool.views', it reported error: "No module named django.db", please check your spelling and sys.path
I've been scouring the web for any solutions. I tried rearranging the import statements within the modules but nothing is working.
sys.path.insert(0, os.path.abspath('/home/tim/Desktop/fqdn/mysite/tool/'))
All my modules are in the tool folder. Any help is desperately needed. Thanks!
Also, doesn't automodule encapsulate autofunction? So why would we ever use autofunction?
You should use MagicMock to simplify the dependencies.
In your conf.py:
from unittest.mock import MagicMock
import sys
MODULES = ['django']
for mod_name in MODULES:
sys.modules[mod_name] = MagicMock()
Related
ModuleNotFoundError: No module named 'context'
I get the following error when I try to run a pyVows test: Traceback (most recent call last): File "C:\Program Files\Python38\lib\unittest\loader.py", line 436, in _find_test_path module = self._get_module_from_name(name) File "C:\Program Files\Python38\lib\unittest\loader.py", line 377, in _get_module_from_name __import__(name) File "D:\Programmierung\Python-Projekte\JourneyMap\JourneyMap\tests.py", line 2, in <module> from django_pyvows.context import DjangoHTTPContext File "C:\Users\malo0\AppData\Roaming\Python\Python38\site-packages\django_pyvows\__init__.py", line 11, in <module> from context import DjangoContext, DjangoHTTPContext ModuleNotFoundError: No module named 'context' I installed pyVows and django-pyvows Am I missing something? I found no helpful documentation REQUESTED EDIT: from pyvows import Vows, expect from django_pyvows.context import DjangoHTTPContext # Create your tests here. #Vows.batch class LanguageTest(Vows.Context): class LanguageSelectIntegrationTest(DjangoHTTPContext): def topic(self): return self.get('/') def test(self, topic): # Test will be here pass
I have installed pytorch, but I still meet bug below
Traceback (most recent call last): File "tools/create_dictionary.py", line 7, in <module> from dataset import Dictionary File "/home/supermicro/xswork/xsvqa/dataset.py", line 6, in <module> import utils File "/home/supermicro/xswork/xsvqa/utils.py", line 7, in <module> import torch ImportError: No module named torch Traceback (most recent call last): File "tools/compute_softscore.py", line 10, in <module> from dataset import Dictionary File "/home/supermicro/xswork/xsvqa/dataset.py", line 6, in <module> import utils File "/home/supermicro/xswork/xsvqa/utils.py", line 7, in <module> import torch ImportError: No module named torch /home/supermicro/xswork/ENV/local/lib/python2.7/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`. from ._conv import register_converters as _register_converters Traceback (most recent call last): File "tools/detection_features_converter.py", line 22, in <module> import utils File "/home/supermicro/xswork/xsvqa/utils.py", line 7, in <module> import torch ImportError: No module named torch
cannot import name path pycall python
where do i find the solution to this ? is in the missing dependencies or in the script? Traceback (most recent call last): File "2.py", line 14, in <module> from pycall.callfile import * File "/usr/lib/python2.6/site-packages/pycall-2.3.0-py2.6.egg/pycall/__init__.py", line 8, in <module> from .callfile import CallFile File "/usr/lib/python2.6/site-packages/pycall-2.3.0-py2.6.egg/pycall/callfile.py", line 11, in <module> from path import path ImportError: cannot import name path
error while executing scikit-learn program in windows
When I execute the following code : from nltk.classify.scikitlearn import SklearnClassifier sklearn.naive_bayes import MultinomialNB,BernoulliNB I am getting an error as follows: Traceback (most recent call last): File "C:\Python27\uni.py", line 2, in <module> from sklearn.naive_bayes import MultinomialNB,BernoulliNB File "C:\Python27\lib\site-packages\sklearn\__init__.py", line 56, in <module> from . import __check_build ImportError: cannot import name __check_build I am new to Python please help me out on how to resolve it
ImportError: cannot import name array, when importing urllib2
I am getting below error when trying to import the urllib2: >>> import urllib2 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib64/python2.7/urllib2.py", line 94, in <module> import httplib File "/usr/lib64/python2.7/httplib.py", line 69, in <module> from array import array ImportError: cannot import name array` Any thoughts on it?
It seems you have a python program named "array.py" in you present working directory. If yes rename that python program or move it to some other directory.