mkdocs: Anaconda Python ImportError: No module named 'mkdocs'

Hi, I’m getting ImportError: No module named 'mkdocs' after calling mkdocs build as shown below.

screen shot 2016-08-01 at 4 21 22 pm

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.

screen shot 2016-08-01 at 4 21 14 pm

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 18 (10 by maintainers)

Most upvoted comments

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 the site_dir, Python considered the site_dir to be a Python module on the PYTHONPATH. Therefore, when running MkDocs, some import would fail because it was trying to import the site_dir rather than the appropriate library (probably because the site_dir was in the cwd). 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 the site_dir cannot be mistaken for a Python module regardless of how Python is configured.