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

I'm get stuck on if __name__ == '__main__': freeze_support() help me :) #12

Open
lskaka opened this issue Jun 7, 2024 · 3 comments
Open

Comments

@lskaka
Copy link

lskaka commented Jun 7, 2024

To Reproduce
Steps to reproduce the behavior:
i'm running this code in visual code :

from ninjemail import Ninjemail

ninja = Ninjemail(
browser="undetected-chrome",
captcha_keys={"capsolver": "keys"},
sms_keys={"5sim": {"token": "keys"}},
auto_proxy=True
)

email, password = ninja.create_gmail_account(
username="username",
password="password",
first_name="Daniel",
last_name="Erfanda",
birthdate="16-02-1982",
use_proxy=True
)

print(f"Email: {email}")
print(f"Password: {password}")

Desktop (please complete the following information):

  • Browser OPERA
  • Version python 3.12.4

Additional context

Traceback (most recent call last):
File "", line 1, in
File "C:\Users\Paulus\AppData\Local\Programs\Python\Python312\Lib\multiprocessing\spawn.py", line 122, in spawn_main
exitcode = _main(fd, parent_sentinel)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Paulus\AppData\Local\Programs\Python\Python312\Lib\multiprocessing\spawn.py", line 131, in _main
prepare(preparation_data)
File "C:\Users\Paulus\AppData\Local\Programs\Python\Python312\Lib\multiprocessing\spawn.py", line 246, in prepare
_fixup_main_from_path(data['init_main_from_path'])
File "C:\Users\Paulus\AppData\Local\Programs\Python\Python312\Lib\multiprocessing\spawn.py", line 297, in _fixup_main_from_path
main_content = runpy.run_path(main_path,
^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 286, in run_path
File "", line 98, in _run_module_code
File "", line 88, in run_code
File "g:\gmailcreator4\ninjemail\test.py", line 10, in
email, password = ninja.create_gmail_account(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "g:\gmailcreator4\ninjemail\ninjemail\ninjemail_manager.py", line 220, in create_gmail_account
driver = create_driver(self.browser, proxy=proxy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "g:\gmailcreator4\ninjemail\ninjemail\utils\webdriver_utils.py", line 200, in create_driver
driver = uc.Chrome(options=options, headless=True, use_subprocess=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Paulus\AppData\Local\Programs\Python\Python312\Lib\site-packages\undetected_chromedriver_init
.py", line 448, in init
self.browser_pid = start_detached(
^^^^^^^^^^^^^^^
File "C:\Users\Paulus\AppData\Local\Programs\Python\Python312\Lib\site-packages\undetected_chromedriver\dprocess.py", line 35, in start_detached
).start()
^^^^^^^
File "C:\Users\Paulus\AppData\Local\Programs\Python\Python312\Lib\multiprocessing\process.py", line 121, in start
self._popen = self._Popen(self)
^^^^^^^^^^^^^^^^^
File "C:\Users\Paulus\AppData\Local\Programs\Python\Python312\Lib\multiprocessing\context.py", line 224, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Paulus\AppData\Local\Programs\Python\Python312\Lib\multiprocessing\context.py", line 337, in _Popen
return Popen(process_obj)
^^^^^^^^^^^^^^^^^^
File "C:\Users\Paulus\AppData\Local\Programs\Python\Python312\Lib\multiprocessing\popen_spawn_win32.py", line 46, in init
prep_data = spawn.get_preparation_data(process_obj._name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Paulus\AppData\Local\Programs\Python\Python312\Lib\multiprocessing\spawn.py", line 164, in get_preparation_data
_check_not_importing_main()
File "C:\Users\Paulus\AppData\Local\Programs\Python\Python312\Lib\multiprocessing\spawn.py", line 140, in _check_not_importing_main
raise RuntimeError('''
RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.

    This probably means that you are not using fork to start your
    child processes and you have forgotten to use the proper idiom
    in the main module:

        if __name__ == '__main__':
            freeze_support()
            ...

    The "freeze_support()" line can be omitted if the program
    is not going to be frozen to produce an executable.

    To fix this issue, refer to the "Safe importing of main module"
    section in https://docs.python.org/3/library/multiprocessing.html
@lskaka lskaka changed the title I'm get stuck on if __name__ == '__main__': freeze_support() help me :) I'm get stuck on if __name__ == '__main__': freeze_support() help me :) Jun 7, 2024
@david96182
Copy link
Owner

You just need to put your code inside a main block like this:

from ninjemail import Ninjemail

if __name__ == '__main__':
    ninja = Ninjemail(
        browser="undetected-chrome",
        captcha_keys={"capsolver": "keys"},
        sms_keys={"5sim": {"token": "keys"}},
        auto_proxy=True
    )

    email, password = ninja.create_gmail_account(
        username="username",
        password="password",
        first_name="Daniel",
        last_name="Erfanda",
        birthdate="16-02-1982",
        use_proxy=True
    )

    print(f"Email: {email}")
    print(f"Password: {password}")

@lskaka
Copy link
Author

lskaka commented Jun 7, 2024

now i'm get error again :

Traceback (most recent call last):
File "", line 1, in
File "C:\Users\Paulus\AppData\Local\Programs\Python\Python312\Lib\multiprocessing\spawn.py", line 122, in spawn_main
exitcode = _main(fd, parent_sentinel)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Paulus\AppData\Local\Programs\Python\Python312\Lib\multiprocessing\spawn.py", line 131, in _main
prepare(preparation_data)
File "C:\Users\Paulus\AppData\Local\Programs\Python\Python312\Lib\multiprocessing\spawn.py", line 246, in prepare
_fixup_main_from_path(data['init_main_from_path'])
File "C:\Users\Paulus\AppData\Local\Programs\Python\Python312\Lib\multiprocessing\spawn.py", line 297, in _fixup_main_from_path
main_content = runpy.run_path(main_path,
^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 286, in run_path
File "", line 98, in _run_module_code
File "", line 88, in _run_code
File "g:\gmailcreator4\ninjemail\test.py", line 15, in
print(f"Email: {email}")
^^^^^
NameError: name 'email' is not defined. Did you mean: 'eval'? Or did you forget to import 'email'?

@david96182
Copy link
Owner

Make sure that this email, password = ninja.create_gmail_account( line is email. If it's good, you can check the logs for more information or debug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants