motdotla / dotenv

Loads environment variables from .env for nodejs projects.
https://www.dotenvx.com
BSD 2-Clause "Simplified" License
19.18k stars 859 forks source link

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

Closed nima10khodaveisi closed 1 year ago

nima10khodaveisi commented 1 year ago

Hey, I'm trying to install dotenv package in my virtual environment using pip but I got this error:

warnings.warn(
        error: subprocess-exited-with-error

        × python setup.py egg_info did not run successfully.
        │ exit code: 1
        ╰─> [16 lines of output]
            Traceback (most recent call last):
              File "<string>", line 2, in <module>
              File "<pip-setuptools-caller>", line 14, in <module>
              File "/tmp/pip-wheel-gp0mn39h/distribute_6b02d663f4734bfa97410a1cfcc26889/setuptools/__init__.py", line 2, in <module>
                from setuptools.extension import Extension, Library
              File "/tmp/pip-wheel-gp0mn39h/distribute_6b02d663f4734bfa97410a1cfcc26889/setuptools/extension.py", line 5, in <module>
                from setuptools.dist import _get_unpatched
              File "/tmp/pip-wheel-gp0mn39h/distribute_6b02d663f4734bfa97410a1cfcc26889/setuptools/dist.py", line 7, in <module>
                from setuptools.command.install import install
              File "/tmp/pip-wheel-gp0mn39h/distribute_6b02d663f4734bfa97410a1cfcc26889/setuptools/command/__init__.py", line 8, in <module>
                from setuptools.command import install_scripts
              File "/tmp/pip-wheel-gp0mn39h/distribute_6b02d663f4734bfa97410a1cfcc26889/setuptools/command/install_scripts.py", line 3, in <module>
                from pkg_resources import Distribution, PathMetadata, ensure_directory
              File "/tmp/pip-wheel-gp0mn39h/distribute_6b02d663f4734bfa97410a1cfcc26889/pkg_resources.py", line 1518, in <module>
                register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
            AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
            [end of output]

I looked online and tried their suggested solution but didn't work. Also, this is the output of pip list:

Package             Version
------------------- ----------
appnope             0.1.3
asgiref             3.7.2
asttokens           2.2.1
backcall            0.2.0
black               23.3.0
certifi             2023.5.7
cfgv                3.3.1
charset-normalizer  3.1.0
click               8.1.3
decorator           5.1.1
distlib             0.3.6
Django              4.2.2
django-stubs        4.2.1
django-stubs-ext    4.2.1
djangorestframework 3.14.0
exceptiongroup      1.1.1
executing           1.2.0
filelock            3.12.1
identify            2.5.24
idna                3.4
iniconfig           2.0.0
ipython             8.14.0
jedi                0.18.2
matplotlib-inline   0.1.6
mypy                1.3.0
mypy-extensions     1.0.0
nodeenv             1.8.0
packaging           23.1
parso               0.8.3
pathspec            0.11.1
pexpect             4.8.0
pickleshare         0.7.5
Pillow              9.5.0
pip                 23.1.2
platformdirs        3.5.3
pluggy              1.0.0
pre-commit          3.3.2
prompt-toolkit      3.0.38
psycopg2            2.9.6
ptyprocess          0.7.0
pure-eval           0.2.2
pycountry           22.3.5
pydantic            1.10.9
Pygments            2.15.1
pytest              7.3.2
pytest-django       4.5.2
python-dotenv       1.0.0
pytz                2023.3
PyYAML              6.0
replicate           0.8.3
requests            2.31.0
setuptools          68.0.0
six                 1.16.0
sqlparse            0.4.4
stack-data          0.6.2
stripe              5.4.0
tomli               2.0.1
traitlets           5.9.0
types-Pillow        9.5.0.6
types-pytz          2023.3.0.0
types-PyYAML        6.0.12.10
types-requests      2.31.0.1
types-stripe        3.5.2.10
types-urllib3       1.26.25.13
typing_extensions   4.6.3
urllib3             2.0.3
virtualenv          20.23.0
wcwidth             0.2.6
wheel               0.40.0

Thanks.

motdotla commented 1 year ago

You've posted on the Node.js repo.

pip is for the python dotenv. Try installing here or here (if you need .env.vault support)