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

Loader FrozenImporter cannot handle module os #4170

Closed
evilvlso opened this issue Apr 12, 2019 · 14 comments
Closed

Loader FrozenImporter cannot handle module os #4170

evilvlso opened this issue Apr 12, 2019 · 14 comments
Labels
solution:not enough info Not enough info has been provided to solve or help. Fill out the issue template

Comments

@evilvlso
Copy link

env:
python : 3.7
pyinstaller :3.4
pyinstaller -F python.py
get this error:

Traceback (most recent call last):
  File "c:\users\administrator\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 438, in get_code
    return self._pyz_archive.extract(fullname)[1]
  File "c:\users\administrator\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\loader\pyimod02_archive.py", line 371, in extract
    obj = zlib.decompress(obj)
zlib.error: Error -3 while decompressing data: incorrect header check

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "site-packages\PyInstaller\loader\pyiboot01_bootstrap.py", line 25, in <module>
  File "c:\users\administrator\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 607, in exec_module
    bytecode = self.get_code(spec.loader_state)
  File "c:\users\administrator\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 440, in get_code
    raise ImportError('Loader FrozenImporter cannot handle module ' + fullname)
ImportError: Loader FrozenImporter cannot handle module os
[5836] Failed to execute script pyiboot01_bootstrap
@evilvlso

This comment has been minimized.

@raza-elahi
Copy link

raza-elahi commented May 24, 2019

PyInstaller: 3.4

  File "/home/raza/.pyenv/versions/anaconda3-4.2.0/envs/mizuho/lib/python3.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 438, in get_code
    return self._pyz_archive.extract(fullname)[1]
  File "/home/raza/.pyenv/versions/anaconda3-4.2.0/envs/mizuho/lib/python3.7/site-packages/PyInstaller/loader/pyimod02_archive.py", line 371, in extract
    obj = zlib.decompress(obj)
zlib.error: Error -3 while decompressing data: incorrect header check

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "site-packages/PyInstaller/loader/pyiboot01_bootstrap.py", line 25, in <module>
  File "/home/raza/.pyenv/versions/anaconda3-4.2.0/envs/mizuho/lib/python3.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 607, in exec_module
    bytecode = self.get_code(spec.loader_state)
  File "/home/raza/.pyenv/versions/anaconda3-4.2.0/envs/mizuho/lib/python3.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 440, in get_code
    raise ImportError('Loader FrozenImporter cannot handle module ' + fullname)
ImportError: Loader FrozenImporter cannot handle module os
[187467] Failed to execute script pyiboot01_bootstrap```

@eputin2

This comment has been minimized.

@raza-elahi
Copy link

raza-elahi commented Jun 12, 2019

I can't call it a solution but I got past the error using command line to add all the data instead of using the spec file.

P.S. By command line I mean that I used "--add-data"

@eputin2
Copy link

eputin2 commented Jun 12, 2019

What data did you add to make this error go away?

@raza-elahi
Copy link

raza-elahi commented Jun 14, 2019

I was using PyInstaller to first generate a spec, modify it to add some files that my code needed, and then ran PyInstaller on the spec file to bundle the code. This wasn't working and causing the error.

I tried using the command line notation for adding the files (pyinstaler code.py --add-data path/to/data ...) and that worked.

@eputin2
Copy link

eputin2 commented Jun 14, 2019

I’m familiar with the errror - I was just wondering what paths to data you used to fix the OS error?

@parthkumargadhiya
Copy link

parthkumargadhiya commented Jul 4, 2019

with:
python : 3.6
pyinstaller :3.4
pyinstaller xyz.spec

I was getting the same error. But I solved it. Can you please post also the .spec file so I can help you. Please also mention which module have you installed along with it.

@la-vie-est-belle
Copy link

la-vie-est-belle commented Jul 6, 2019

I got the same error. Got it when I tried to use --key to encrypt the exe.

Did't use any files or datas:

import requests
from bs4 import BeautifulSoup


def get_page_source(page_num):
    print('Crawling page %d' % page_num)

    url = 'http://books.toscrape.com/catalogue/page-%d.html' % page_num
    r = requests.get(url)
    return r.text


def get_book_info(page_source):
    soup = BeautifulSoup(page_source, features='lxml')
    titles = soup.select('h3 > a')
    for title in titles:
        print(title.get('title'))


if __name__ == '__main__':
    # 1-50
    for i in range(1, 51):
        page_source = get_page_source(i)
        get_book_info(page_source)

@parthkumargadhiya
Copy link

parthkumargadhiya commented Jul 8, 2019

I think you are using pycryptodome. Use pycrypto module to avoid Loader FrozenImporter cannot handle module os error.

Installing on Windows

  1. Install Python 3.x
  2. Install Visual C++ Build Tools
  3. Install pycrypto module
    cd "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build"
    vcvarsall.bat x86_amd64
    cd %VCINSTALLDIR%
    for /R %f in (*stdint.h) do set CL=-FI"%f"
    pip install pycrypto

This will work and able to encrypt the executable file using the .spec file or direct. :)

@htgoebel
Copy link
Member

@evilvlso

  1. Try removing the build and dist directory, then run PyInstaller with --clean.
  2. --key is is not supported.

Otherwise please provide more details, see How to report Bugs. Esp. please provide a minimal example to reproduce the error.

@htgoebel htgoebel added the state:need info Need more information for solve or help. label Jul 16, 2019
@htgoebel
Copy link
Member

htgoebel commented Aug 7, 2019

No response for 4 month. closing.

@htgoebel htgoebel closed this as completed Aug 7, 2019
@htgoebel htgoebel added solution:not enough info Not enough info has been provided to solve or help. Fill out the issue template and removed state:need info Need more information for solve or help. labels Aug 7, 2019
@px528
Copy link

px528 commented Aug 30, 2019

If this issue happened in linux, just replace pycryptodome with pycrypto.

@fengerzh
Copy link

fengerzh commented Jul 5, 2021

My case is Windows Defender automatically delete my exe file caused this error. If disable Windows Defender, everything works fine.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
solution:not enough info Not enough info has been provided to solve or help. Fill out the issue template
Projects
None yet
Development

No branches or pull requests

8 participants