Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'importlib._bootstrap' has no attribute 'SourceLoader'

I'm trying to build an app with cx_freeze and esky. It was working before (ok, maybe some months ago. Since then, python 3.5 went out).

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'm using:

  • Python 3.5.0
  • Esky 0.9.9 (latest) from pypi
  • cx_freeze 4.3.4-2

And I'm on Manjaro (Linux). I can not figure out where the problem comes from. Could you give me a hand please ?

like image 386
JPFrancoia Avatar asked Oct 27 '15 10:10

JPFrancoia


4 Answers

Run this Command, it will fix your problem

python3 -m ensurepip --upgrade
like image 169
pd farhad Avatar answered Nov 01 '22 16:11

pd farhad


I was able to fix the issue by running:

pip3 uninstall setuptools
pip3 install setuptools
like image 21
Shingboo Avatar answered Nov 01 '22 17:11

Shingboo


I ran into this same problem today.

Running the following commands in terminal resolved my problem.

➜  ~ pip install --upgrade pip
➜  ~ pip install --upgrade virtualenvwrapper
➜  ~ mkvirtualenv -p /usr/local/bin/python3 test_env
like image 29
Justin Beall Avatar answered Nov 01 '22 17:11

Justin Beall


mmm there might be a bug there looking at the source code:

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 to replace that line with:

loader = importlib._bootstrap_external.SourceLoader()

If that works then try using a lesser version than 3.5 and submit a bug in their github issue page.

like image 45
lapinkoira Avatar answered Nov 01 '22 16:11

lapinkoira