AttributeError:模块“ importlib._bootstrap”没有属性“ SourceFileLoader”

时间:2019-02-08 06:49:07

标签: python django python-3.x pip

我是编程新手,所以遇到了这个麻烦。 我已经升级了点子,然后使用点子列表,ipython笔记本,jupyter笔记本来使用anaconda,所以在完成所有这些命令后,我得到了一个答案:

Traceback (most recent call last):
  File "/home/bakhytgul/anaconda3/bin/pip", line 7, in <module>
    from pip._internal import main
  File "/home/bakhytgul/anaconda3/lib/python3.6/site-packages/pip/_internal/__init__.py", line 40, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/home/bakhytgul/anaconda3/lib/python3.6/site-packages/pip/_internal/cli/autocompletion.py", line 8, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/home/bakhytgul/anaconda3/lib/python3.6/site-packages/pip/_internal/cli/main_parser.py", line 12, in <module>
    from pip._internal.commands import (
  File "/home/bakhytgul/anaconda3/lib/python3.6/site-packages/pip/_internal/commands/__init__.py", line 6, in <module>
    from pip._internal.commands.completion import CompletionCommand
  File "/home/bakhytgul/anaconda3/lib/python3.6/site-packages/pip/_internal/commands/completion.py", line 6, in <module>
    from pip._internal.cli.base_command import Command
  File "/home/bakhytgul/anaconda3/lib/python3.6/site-packages/pip/_internal/cli/base_command.py", line 19, in <module>
    from pip._internal.download import PipSession
  File "/home/bakhytgul/anaconda3/lib/python3.6/site-packages/pip/_internal/download.py", line 15, in <module>
    from pip._vendor import requests, six, urllib3
  File "/home/bakhytgul/anaconda3/lib/python3.6/site-packages/pip/_vendor/requests/__init__.py", line 97, in <module>
    from pip._vendor.urllib3.contrib import pyopenssl
  File "/home/bakhytgul/anaconda3/lib/python3.6/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in <module>
    import OpenSSL.SSL
  File "/home/bakhytgul/anaconda3/lib/python3.6/site-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import rand, crypto, SSL
  File "/home/bakhytgul/anaconda3/lib/python3.6/site-packages/OpenSSL/crypto.py", line 13, in <module>
    from cryptography.hazmat.primitives.asymmetric import dsa, rsa
  File "/home/bakhytgul/anaconda3/lib/python3.6/site-packages/cryptography/hazmat/primitives/asymmetric/rsa.py", line 14, in <module>
    from cryptography.hazmat.backends.interfaces import RSABackend
  File "/home/bakhytgul/anaconda3/lib/python3.6/site-packages/cryptography/hazmat/backends/__init__.py", line 7, in <module>
    import pkg_resources
  File "/home/bakhytgul/anaconda3/lib/python3.6/site-packages/pkg_resources.py", line 1435, in <module>
    register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'

请问您能帮我解决这个问题吗?十分感谢。 我在用着: -Ubuntu 16.04。 (64位) -Python 2.7.12 -Python 3.6.0 :: Anaconda 4.3.1(64位)

P.S:我尝试使用dotenv进行修复,请确保pip(这使我得到答案是我没有此软件包)。

1 个答案:

答案 0 :(得分:1)

不是一个完整的答案,因为我无法告诉您为什么会发生这种情况,但是希望这可以帮助您找到解决方案。

我曾经遇到过这个问题。当我从头开始尝试构建rjsmin时,一切顺利,那是当我注意到原因是失败的venv使用的是Python 3.6,而新的venv使用的是Python 3.7。

根据您的控制台输出,您正在使用3.6的anaconda,我认为您可能已通过使用pip手动升级软件包来破坏安装。您可以尝试获取较新版本的anaconda,或进行全新安装。