probberechts / soccerdata

⛏⚽ Scrape soccer data from Club Elo, ESPN, FBref, FiveThirtyEight, Football-Data.co.uk, FotMob, Sofascore, SoFIFA, Understat and WhoScored.
https://soccerdata.readthedocs.io/en/latest/
Other
544 stars 95 forks source link

[WhoScored] Module not working #54

Closed gbordapoo closed 2 years ago

gbordapoo commented 2 years ago

Which Python version are you using?

Python 3.9.12

Which version of soccerdata are you using?

import soccerdata as sd ws = sd.WhoScored(proxy='tor')

What did you do?

Install soccerdata with 'python3 -m pip install soccerdata'

What did you expect to see?

create ws variable

What did you see instead?

Output from spyder call 'get_cwd': [06/05/22 22:08:48] INFO Saving cached data to /Users/gustavob _common.py\:\91\ orda/soccerdata/data/WhoScored
[06/05/22 22:08:50] INFO patching driver executable /Users/gu \patcher.py\:\231\ stavoborda/Library/Application Suppo
rt/undetected_chromedriver/b170e9511
dda09d2_chromedriver
[06/05/22 22:08:50] INFO No custom team name replacements _config.py:85 found. You can configure these in /Us
ers/gustavoborda/soccerdata/config/te
amname_replacements.json.
INFO No custom league dict found. You can _config.py:155 configure additional leagues in /Use
rs/gustavoborda/soccerdata/config/le
ague_dict.json.
INFO Saving cached data to /Users/gustavob _common.py:91 orda/soccerdata/data/WhoScored
[06/05/22 22:08:52] INFO patching driver executable /Users/gu patcher.py:231 stavoborda/Library/Application Suppo
rt/undetected_chromedriver/a44ea0bfa
6137f97_chromedriver

Output from spyder call 'get_cwd':


1 spawn.py 116 spawn_main exitcode = _main(fd, parent_sentinel) spawn.py 125 _main prepare(preparation_data) spawn.py 236 prepare _fixup_main_from_path(data['init_main_from_path']) spawn.py 287 _fixup_main_from_path main_content = runpy.run_path(main_path, runpy.py 268 run_path return _run_module_code(code, init_globals, run_name, runpy.py 97 _run_module_code _run_code(code, mod_globals, init_globals, runpy.py 87 _run_code exec(code, run_globals) untitled0.py 3 ws = sd.WhoScored(proxy='tor') whoscored.py 87 __init__ super().__init__( _common.py 383 __init__ self._driver = self._init_webdriver() _common.py 410 _init_webdriver return uc.Chrome(options=chrome_options) __init__.py 388 __init__ self.browser_pid = start_detached( dprocess.py 30 start_detached multiprocessing.Process( process.py 121 start self._popen = self._Popen(self) context.py 224 _Popen return _default_context.get_context().Process._Popen(process_obj) context.py 284 _Popen return Popen(process_obj) popen_spawn_posix.py 32 __init__ super().__init__(process_obj) popen_fork.py 19 __init__ self._launch(process_obj) popen_spawn_posix.py 42 _launch prep_data = spawn.get_preparation_data(process_obj._name) spawn.py 154 get_preparation_data _check_not_importing_main() spawn.py 134 _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.
probberechts commented 2 years ago

This is a frequently recurring issue in the undetected-chromedriver repo. See for example, #561. Basically, you have to protect the constructor when you run it from a script.

import soccerdata as sd
if __name__ == '__main__':
    ws = sd.WhoScored(proxy='tor')