Faker package

MRAB python at mrabarnett.plus.com
Fri Jun 18 22:10:41 EDT 2021


On 2021-06-19 02:51, Rich Shepard wrote:
> On Sat, 19 Jun 2021, MRAB wrote:
> 
>> When it says "command line" it means the operating system's command line. If 
>> it's the Python shell , it'll say "Python shell" or "Python prompt.
> 
> MRAB,
> 
> The root shell's (#) what I assumed. User shells (in bash, anyway) have $ as
> the prompt.
> 
> Regardless,
> 
> $ faker -o temp.out faker.names()
> -bash: syntax error near unexpected token `('
> [rshepard at salmo ~]$ faker -o temp.out faker.names
> Traceback (most recent call last):
>     File "/usr/bin/faker", line 8, in <module>
>       sys.exit(execute_from_command_line())
>     File "/usr/lib64/python3.7/site-packages/faker/cli.py", line 264, in execute_from_command_line
>       command.execute()
>     File "/usr/lib64/python3.7/site-packages/faker/cli.py", line 246, in execute
>       includes=arguments.include,
>     File "/usr/lib64/python3.7/site-packages/faker/cli.py", line 67, in print_doc
>       provider_or_field], includes=includes)
>     File "/usr/lib64/python3.7/site-packages/faker/proxy.py", line 63, in __init__
>       **config)
>     File "/usr/lib64/python3.7/site-packages/faker/factory.py", line 56, in create
>       prov_cls, lang_found = cls._get_provider_class(prov_name, locale)
>     File "/usr/lib64/python3.7/site-packages/faker/factory.py", line 68, in _get_provider_class
>       provider_class = cls._find_provider_class(provider, locale)
>     File "/usr/lib64/python3.7/site-packages/faker/factory.py", line 90, in _find_provider_class
>       provider_module = import_module(provider_path)
>     File "/usr/lib64/python3.7/importlib/__init__.py", line 127, in import_module
>       return _bootstrap._gcd_import(name[level:], package, level)
>     File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
>     File "<frozen importlib._bootstrap>", line 983, in _find_and_load
>     File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
> ModuleNotFoundError: No module named 'faker.names'
> [rshepard at salmo ~]$
> 
> It does not work from the bash command line as a user or as root.
> 
>> The "root shell prompt (#)" suggests to  me that it's Linux, so if you're 
>> using Windows you'll need to use the equivalent for Windows.
> 
> I don't do windows; defenestrated 24 years ago.
> 
It looks like you're mixing some Python usage ("faker.names()") in with 
command line usage.

Judging from the docs, I'd say you need something more like:

     $ faker -o temp.out name

for 1 fake name or:

     $ faker -r=10 -o temp.out name

for 10 fake names.


More information about the Python-list mailing list