Problem with a module called Faker(generates fake Data).

1,078 views
Skip to first unread message

nikola zagorski

unread,
Jan 29, 2016, 5:54:32 AM1/29/16
to PyInstaller
Traceback (most recent call last):
 File "<string>", line 4, in <module>
 File "c:\users\mnqko\appdata\local\programs\python\python35-32\lib\site-packages\PyInstaller\loader\pyimod03_importer
.py", line 389, in load_module
   exec(bytecode, module.__dict__)
 File "site-packages\faker\__init__.py", line 4, in <module>
 File "c:\users\mnqko\appdata\local\programs\python\python35-32\lib\site-packages\PyInstaller\loader\pyimod03_importer
.py", line 389, in load_module
   exec(bytecode, module.__dict__)
 File "site-packages\faker\factory.py", line 10, in <module>
 File "c:\users\mnqko\appdata\local\programs\python\python35-32\lib\site-packages\PyInstaller\loader\pyimod03_importer
.py", line 389, in load_module
   exec(bytecode, module.__dict__)
 File "site-packages\faker\config.py", line 11, in <module>
 File "site-packages\faker\config.py", line 11, in <listcomp>
 File "importlib\__init__.py", line 126, in import_module
ImportError: No module named 'faker.providers'
Autoform returned -1


Hello,
i've made a simple script that fills up a form on a page with fake data, which  is generated through a module called Faker.
the problem is that it can't find a certain module "faker.providers", but the script works without a problem when ran from PyCharm.
The things that i've tried so far:hidden import,hook.

Could you please give me some advice how to proceed? 


Thanks In Advance

Nikola Zagorski









example.py

Hartmut Goebel

unread,
Jan 29, 2016, 9:47:15 AM1/29/16
to pyins...@googlegroups.com
Am 28.01.2016 um 21:30 schrieb nikola zagorski:
Could you please give me some advice how to proceed? 

You can find many tips for tracking this down in the wiki:
https://github.com/pyinstaller/pyinstaller/wiki/If-Things-Go-Wrong

--
Schönen Gruß
Hartmut Goebel
Dipl.-Informatiker (univ), CISSP, CSSLP
Information Security Management, Security Governance, Secure Software Development

Goebel Consult, Landshut
http://www.goebel-consult.de

Blog: http://www.goebel-consult.de/blog/bestanden-iso-27001-lead-implementer
Kolumne: http://www.cissp-gefluester.de/2011-02-fleisige-datensammler-fur-lukratives-geschaeftsmodell-gesucht

nikola zagorski

unread,
Feb 3, 2016, 3:57:25 AM2/3/16
to PyInstaller
Well i've checked the link that you provided,but still i am facing the same issue. Maybe  the problem is that the module loads dynamic random data when the app has been started. I've tried dynamic hooks, hiddenimports and everything possible,but still can't figure out why it can't find the module. In --onedir mode i can see the module is missing but that doesn't help me too much.


Have a Nice Day

Nikola 


Jonathan Stewmon

unread,
Feb 3, 2016, 11:53:54 AM2/3/16
to pyins...@googlegroups.com

I got this working using a hook for faker. The trick is to collect both submodules and data files from faker.providers.

tree:

.
├── example.py
└── pyinstaller
    ├── hook-faker.py

example.py:

$ cat example.py
from faker import Faker
fake = Faker()

print fake.password(
    length=3,
    special_chars=False,
    digits=True,
    upper_case=False,
    lower_case=True
)

print fake.domain_name()

pyinstaller/hook-faker.py:

from PyInstaller.utils.hooks import collect_submodules, collect_data_files
hiddenimports = collect_submodules('faker', 'providers')
datas = collect_data_files('faker.providers', include_py_files=True)

build command:

$ pyinstaller --clean --distpath dist --name example --additional-hooks-dir pyinstaller/ example.py

run bundle:

$ ./dist/example/example
wwg
kulas.com

--
You received this message because you are subscribed to the Google Groups "PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyinstaller...@googlegroups.com.
To post to this group, send email to pyins...@googlegroups.com.
Visit this group at https://groups.google.com/group/pyinstaller.
For more options, visit https://groups.google.com/d/optout.



This e-mail, including attachments, contains confidential and/or proprietary information, and may be used only by the person or entity to which it is addressed. The reader is hereby notified that any dissemination, distribution or copying of this e-mail is prohibited. If you have received this e-mail in error, please notify the sender by replying to this message and delete this e-mail immediately.

nikola zagorski

unread,
Feb 5, 2016, 5:21:18 AM2/5/16
to PyInstaller
Thanks for the reply,
 
i managed to run it with py2exe

i would've never thought about this. 

have a Nice day

Nikola .  
Reply all
Reply to author
Forward
0 new messages