Search code examples
python-3.xpython-venv

AttributeError: module 'importlib.machinery' has no attribute 'BuiltinImporter' when creating venv


When I try to create a virtual env with python3 (python3 -m venv <ENV_NAME>), I get the following error:

python3.7 -m venv watcher                                                                                  hossein@hostMHY12
Could not import runpy module
Traceback (most recent call last):
  File "/Users/<USER_NAME>/miniconda3/lib/python3.7/runpy.py", line 15, in <module>
    import importlib.util
  File "/Users/<USER_NAME>/miniconda3/lib/python3.7/importlib/util.py", line 9, in <module>
    from . import abc
  File "/Users/<USER_NAME>/miniconda3/lib/python3.7/importlib/abc.py", line 83, in <module>
    _register(MetaPathFinder, machinery.BuiltinImporter, machinery.FrozenImporter,
AttributeError: module 'importlib.machinery' has no attribute 'BuiltinImporter'

This is a strange error, and I couldn't find any answers online. Any help is appreciated.


Solution

  • This issue in my case was some sort of conflict with my miniconda. Once I removed it as explained in this link, everything was fine.