'importlib._bootstrap' does not have the attribute 'SourceLoader'

I am trying to create an application with cx_freeze and esky. It worked before (well, maybe a few months ago. Since then python 3.5 has been released).

I have the following exception:

File "/usr/lib/python3.5/site-packages/esky/util.py", line 578, in compile_to_bytecode loader = importlib._bootstrap.SourceLoader() AttributeError: module 'importlib._bootstrap' has no attribute 'SourceLoader' 

I use:

  • Python 3.5.0
  • Esky 0.9.9 (last) of pypi
  • cx_freeze 4.3.4-2

And I am in Manjaro (Linux). I can’t understand where this problem comes from. Could you give me a hand?

+7
python cx-freeze esky
source share
2 answers

mmm may be a source related error:

 if sys.version_info[:2] < (3, 1): bytecode = imp.get_magic() + struct.pack("<i", 0) bytecode += marshal.dumps(compile(source_code, compile_filename, "exec")) elif sys.version_info[:2] < (3, 4): bytecode = imp.get_magic() + struct.pack("<ii", 0, 0) bytecode += marshal.dumps(compile(source_code, compile_filename, "exec")) else: loader = importlib._bootstrap.SourceLoader() code = loader.source_to_code(source_code, '<string>') bytecode = importlib._bootstrap._code_to_bytecode(code, mtime=0, source_size=0) 

Can you try replacing this line:

loader = importlib._bootstrap_external.SourceLoader()

If this works, try using a smaller version than 3.5 and send an error message on the github problem page.

+2
source share

Today I ran into this problem.

Running the following commands in the terminal resolved my problem.

 ➜ ~ pip install --upgrade pip ➜ ~ pip install --upgrade virtualenvwrapper ➜ ~ mkvirtualenv -p /usr/local/bin/python3 test_env 
+6
source share

All Articles