Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader' #113

Closed
nathandcornell opened this issue May 21, 2018 · 8 comments

Comments

@nathandcornell
Copy link

I get this error when trying to install with pip3 or pipenv.

Full trace:

~  pip3 install --user dotenv
Collecting dotenv
  Using cached https://files.pythonhosted.org/packages/e2/46/3754073706e31670eed18bfa8a879305b56a471db15f20523c2427b10078/dotenv-0.0.5.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "/usr/local/lib/python3.6/site-packages/setuptools/sandbox.py", line 154, in save_modules
        yield saved
      File "/usr/local/lib/python3.6/site-packages/setuptools/sandbox.py", line 194, in setup_context
        __import__('setuptools')
      File "/private/var/folders/9h/tnvh3n990gn5qz49r58n1lrc0000gn/T/easy_install-qtm9m32i/distribute-0.7.3/setuptools/__init__.py", line 2, in <module>
      File "/private/var/folders/9h/tnvh3n990gn5qz49r58n1lrc0000gn/T/easy_install-qtm9m32i/distribute-0.7.3/setuptools/extension.py", line 5, in <module>
      File "/private/var/folders/9h/tnvh3n990gn5qz49r58n1lrc0000gn/T/easy_install-qtm9m32i/distribute-0.7.3/setuptools/dist.py", line 7, in <module>
      File "/private/var/folders/9h/tnvh3n990gn5qz49r58n1lrc0000gn/T/easy_install-qtm9m32i/distribute-0.7.3/setuptools/command/__init__.py", line 8, in <module>
      File "/private/var/folders/9h/tnvh3n990gn5qz49r58n1lrc0000gn/T/easy_install-qtm9m32i/distribute-0.7.3/setuptools/command/install_scripts.py", line 3, in <module>
      File "/private/var/folders/9h/tnvh3n990gn5qz49r58n1lrc0000gn/T/easy_install-qtm9m32i/distribute-0.7.3/pkg_resources.py", line 1518, in <module>
    AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/9h/tnvh3n990gn5qz49r58n1lrc0000gn/T/pip-install-88luf9yh/dotenv/setup.py", line 23, in <module>
        scripts=['scripts/dotenv']
      File "/usr/local/lib/python3.6/site-packages/setuptools/__init__.py", line 128, in setup
        _install_setup_requires(attrs)
      File "/usr/local/lib/python3.6/site-packages/setuptools/__init__.py", line 123, in _install_setup_requires
        dist.fetch_build_eggs(dist.setup_requires)
      File "/usr/local/lib/python3.6/site-packages/setuptools/dist.py", line 513, in fetch_build_eggs
        replace_conflicting=True,
      File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 774, in resolve
        replace_conflicting=replace_conflicting
      File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1057, in best_match
        return self.obtain(req, installer)
      File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1069, in obtain
        return installer(requirement)
      File "/usr/local/lib/python3.6/site-packages/setuptools/dist.py", line 580, in fetch_build_egg
        return cmd.easy_install(req)
      File "/usr/local/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 673, in easy_install
        return self.install_item(spec, dist.location, tmpdir, deps)
      File "/usr/local/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 699, in install_item
        dists = self.install_eggs(spec, download, tmpdir)
      File "/usr/local/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 884, in install_eggs
        return self.build_and_install(setup_script, setup_base)
      File "/usr/local/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 1152, in build_and_install
        self.run_setup(setup_script, setup_base, args)
      File "/usr/local/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 1138, in run_setup
        run_setup(setup_script, args)
      File "/usr/local/lib/python3.6/site-packages/setuptools/sandbox.py", line 233, in run_setup
        with setup_context(setup_dir):
      File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/contextlib.py", line 81, in __enter__
        return next(self.gen)
      File "/usr/local/lib/python3.6/site-packages/setuptools/sandbox.py", line 195, in setup_context
        yield
      File "/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6/lib/python3.6/contextlib.py", line 99, in __exit__
        self.gen.throw(type, value, traceback)
      File "/usr/local/lib/python3.6/site-packages/setuptools/sandbox.py", line 166, in save_modules
        saved_exc.resume()
      File "/usr/local/lib/python3.6/site-packages/setuptools/sandbox.py", line 141, in resume
        six.reraise(type, exc, self._tb)
      File "/usr/local/lib/python3.6/site-packages/setuptools/_vendor/six.py", line 685, in reraise
        raise value.with_traceback(tb)
      File "/usr/local/lib/python3.6/site-packages/setuptools/sandbox.py", line 154, in save_modules
        yield saved
      File "/usr/local/lib/python3.6/site-packages/setuptools/sandbox.py", line 194, in setup_context
        __import__('setuptools')
      File "/private/var/folders/9h/tnvh3n990gn5qz49r58n1lrc0000gn/T/easy_install-qtm9m32i/distribute-0.7.3/setuptools/__init__.py", line 2, in <module>
      File "/private/var/folders/9h/tnvh3n990gn5qz49r58n1lrc0000gn/T/easy_install-qtm9m32i/distribute-0.7.3/setuptools/extension.py", line 5, in <module>
      File "/private/var/folders/9h/tnvh3n990gn5qz49r58n1lrc0000gn/T/easy_install-qtm9m32i/distribute-0.7.3/setuptools/dist.py", line 7, in <module>
      File "/private/var/folders/9h/tnvh3n990gn5qz49r58n1lrc0000gn/T/easy_install-qtm9m32i/distribute-0.7.3/setuptools/command/__init__.py", line 8, in <module>
      File "/private/var/folders/9h/tnvh3n990gn5qz49r58n1lrc0000gn/T/easy_install-qtm9m32i/distribute-0.7.3/setuptools/command/install_scripts.py", line 3, in <module>
      File "/private/var/folders/9h/tnvh3n990gn5qz49r58n1lrc0000gn/T/easy_install-qtm9m32i/distribute-0.7.3/pkg_resources.py", line 1518, in <module>
    AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/9h/tnvh3n990gn5qz49r58n1lrc0000gn/T/pip-install-88luf9yh/dotenv/

Versions:

~  python --version
Python 3.6.5
~  pip --version
pip 10.0.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)
~  pipenv --version
pipenv, version 11.10.4
@byronvanstien
Copy link

Also experiencing this issue, although on Python 3.7.0a4

@bertday
Copy link

bertday commented May 30, 2018

Also having this issue, Python 3.6.5 and installing via pipenv.

@danmackinlay
Copy link

Yes, I'm having this problem on

  • python 3.6.4 64 bit anaconda, and
  • python 3.6.5 installed via linuxbrew
    both on ubuntu 16.04.

However, it works fine on OSX via all the python interpreters I have there (homebrew install, system, anaconda).

On OSX and Ubuntu, other packages apart from dotenv install via pip just fine. This is specific to dotenv+Ubuntu for me. Is that the case for others?

searching for AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader' on google reveals many occurrences of this error, but mostly they seem to be about pip being entirely broken, not one specific package

I can't work out how to drop into debugger when running pip install (because it calls sys.exit()) so I haven't proceeded far in debugging this, and I am on an unrelated deadline, so let me share my workaround for now - download dotenv (or clone from github) and run pip install -e . from the download dir.

@fourjr
Copy link

fourjr commented Jun 2, 2018

You are installing the wrong package, do pip install python-dotenv

@nathandcornell
Copy link
Author

LOL, thanks! I like an easy fix. 😄

@jchao09
Copy link

jchao09 commented Jul 9, 2018

python-dotenv is not a fix for me. I have it installed in my virtualenv

Requirement already satisfied: python-dotenv in /usr/local/lib/python3.6/site-packages (0.8.2)

but when I start my django app, it still complains about

Traceback (most recent call last):
  File "server.py", line 8, in <module>
    from dotenv import load_dotenv, find_dotenv
ModuleNotFoundError: No module named 'dotenv'

@fourjr
Copy link

fourjr commented Jul 10, 2018

that's not the same issue as mentioned in this issue, and that's probably a virtualenv issue

@martinwunderlich-celonis

Had the same issue with Python 3.11, Pip 23.3.2 and Mac Os Ventura 13.6.3. Changing the package to python-dotenv solved the problem. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants