mkdocs: Anaconda Python ImportError: No module named 'mkdocs'
Hi, I’m getting ImportError: No module named 'mkdocs' after calling mkdocs build as shown below.
I’ve tried upgrading pip and uninstalling and reinstalling mkdocs but still obtained the same error. Any idea of how may I fixed this? Thanks.
pip and mkdocs’s version are printed below.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 18 (10 by maintainers)
Taking another look at this issue, I am certain this is a symptom of #807, which was fixed in version 0.16 (see ac2ff10afd). And all previous reports of this problem were made before 0.16 was released. With the confirmation from @nathancarter that updating to 0.16+ resolves the problem on a system on which it existed, I’m closing this as a duplicate of #807.
By way of explanation, my assumption is that because some Python files (at least
__init__.py) were being copied into thesite_dir, Python considered thesite_dirto be a Python module on the PYTHONPATH. Therefore, when running MkDocs, some import would fail because it was trying to import thesite_dirrather than the appropriate library (probably because thesite_dirwas in thecwd). However, different systems (even different Python installs on the same system) can be configured to resolve PYTHONPATH differently, so it was difficult to reproduce by others. And when you can’t reproduce it, it’s really hard to debug. In the end, it appears that Anaconda was a red herring. While it is apparently one of the systems who’s default configuration in such that the problem arises, it would by no means be the only system which could have that configuration. Presumably, now that we know the cause, the problem could be reproduced (with MkDocs version 0.15.x) on any system with a few minor adjustments to how PYTHONPATH is resolved. Regardless, the correct fix has already been made in 0.16, which ensures that thesite_dircannot be mistaken for a Python module regardless of how Python is configured.