Operational Defect Database

BugZero found this defect 2500 days ago.

MongoDB | 375785

[SERVER-28879] MongoDB failed to build due to ImportError: No module named typing.

Last update date:


Affected products:

MongoDB Server

Affected releases:

No affected releases provided.

Fixed releases:

No fixed releases provided.



I tried to build MongoDB with master branch latest revision on Windows. It failed to build due to ImportError: No module named typing. This issue can be repro from revision c776e095 (https://github.com/mongodb/mongo/commit/c776e095ac25d0426624f4a84c03f0094c3c661f). Python module typing is supported from python 3.5. But SCons does not run under Python version 3.5. Python 3 and above are not yet supported. Could you please take a look at this? Thanks! You can repro this issue as the steps below: 1. git clone -c core.autocrlf=true https://github.com/mongodb/mongo D:\MongoDB\src 2. Open a VS 2015 x64 command prompt and browse to D:\MongoDB\src 3. scons all -j4 Error info: C:\tools\Python2\python.exe buildscripts/idl/idlc.py --base_dir build/opt --header build\opt\mongo\idl\unittest_gen.h --output build\opt\mongo\idl\unittest_gen.cpp src\mongo\idl\unittest.idl Traceback (most recent call last): File "buildscripts/idl/idlc.py", line 23, in <module> import idl.compiler File "D:\MongoDB\src\buildscripts\idl\idl\compiler.py", line 26, in <module> from typing import Any, List ImportError: No module named typing scons: *** [build\opt\mongo\idl\unittest_gen.cpp] Error 1

Top User Comments

karenhuang2017 commented on Fri, 21 Apr 2017 05:42:02 +0000: Thanks for your quick response! Running command "pip.exe install -r buildscripts\requirements.txt" can install typing module. And this resolved my problem. Thank you again! mark.benvenuto commented on Thu, 20 Apr 2017 14:48:56 +0000: Yes, I could just import typing and yaml. These are the only two strictly needed, and I do not believe these requirements are going to grow any time soon. This would work as long as scons and the idl compiler use the same version of python. behackett commented on Thu, 20 Apr 2017 14:44:41 +0000: It looks like you could attempt to import all necessary modules in idl.py behackett commented on Thu, 20 Apr 2017 14:41:11 +0000: Can you import packages during the build process? Most of those requirements aren't actually needed to build the server. You could just try to import typing and re-raise ImportError with a more helpful error message if it's not available. mark.benvenuto commented on Thu, 20 Apr 2017 14:35:23 +0000: There are a few options: You could use pkg_resources if the setuptools is installed. This is an optional site-package, and you would need to duplicate the contents of requirements.txt into python code. You could runl pip check if pip is installed and the user has a recent version (> 8.0 I believe is the minimum, 1.x does not work). This is also optional site-package. You would then either try to search for the pip executable or try to load the pip program into the current python interpreter. acm commented on Thu, 20 Apr 2017 14:13:06 +0000: mark.benvenuto - Can we look into having SCons at startup probe the python environment for the requirements in the requirements.txt file and give a helpful error if they are not satisfied? mark.benvenuto commented on Thu, 20 Apr 2017 14:04:39 +0000: We have a python requirements file here: https://github.com/mongodb/mongo/blob/master/buildscripts/requirements.txt You can setup the necessary python modules for building by running: pip.exe install -r buildscripts\requirements.txt Also, please note that only VS 2015 is supported at this time. VS 2017 RTM is not supported by either SCons or the MongoDB source code.

Additional Resources / Links


BugZero Risk Score

Coming soon



Have you been affected by this bug?


Do you know how much operational outages are costing you?

Understand the cost to your business and how BugZero can help you reduce those costs.


Login to read and write comments.

Have you ever...

had your data corrupted from a