As in title, I’m encountering the following Runtime Error, while trying to featurize in Spyder IDE (the whole thing goes smoothly in jupyter notebook).
Below the code and the error, has anybody encountered the same?
from matminer.featurizers.conversions import StrToComposition
from multiprocessing import Process, freeze_support
from matminer.featurizers.composition import ElementProperty
from matminer.featurizers.conversions import StrToComposition
from multiprocessing import Process, freeze_support
from matminer.featurizers.composition import ElementProperty
import numpy as np
import tqdm
import pandas as pd
from preprocess_datasets import clean_MPDS_dataset, remove_correlated_features, preprocessing
df = pd.read_csv('./datasets/data.csv', index_col=0)
stc = StrToComposition()
el = ElementProperty.from_preset('magpie')
df = stc.featurize_dataframe(df, 'formula', ignore_errors = True)
StrToComposition: 0%| | 0/6229 [00:00<?, ?it/s]C:\Users\hp\Desktop\PHD\Projects\MY_MODELS\TCOPredictor\preprocess_datasets.py:6: FutureWarning: The default value of regex will change from True to False in a future version. In addition, single character regular expressions will *not* be treated as literal strings when regex=True.
df['formula'] = df['formula'].str.replace('[','')
C:\Users\hp\Desktop\PHD\Projects\MY_MODELS\TCOPredictor\preprocess_datasets.py:7: FutureWarning: The default value of regex will change from True to False in a future version. In addition, single character regular expressions will *not* be treated as literal strings when regex=True.
df['formula'] = df['formula'].str.replace(']','')
StrToComposition: 0%| | 0/6229 [00:00<?, ?it/s]Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\hp\anaconda3\envs\MLforChemistry\lib\multiprocessing\spawn.py", line 116, in spawn_main
exitcode = _main(fd, parent_sentinel)
File "C:\Users\hp\anaconda3\envs\MLforChemistry\lib\multiprocessing\spawn.py", line 125, in _main
prepare(preparation_data)
File "C:\Users\hp\anaconda3\envs\MLforChemistry\lib\multiprocessing\spawn.py", line 236, in prepare
_fixup_main_from_path(data['init_main_from_path'])
File "C:\Users\hp\anaconda3\envs\MLforChemistry\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path
main_content = runpy.run_path(main_path,
File "C:\Users\hp\anaconda3\envs\MLforChemistry\lib\runpy.py", line 265, in run_path
return _run_module_code(code, init_globals, run_name,
File "C:\Users\hp\anaconda3\envs\MLforChemistry\lib\runpy.py", line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "C:\Users\hp\anaconda3\envs\MLforChemistry\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\hp\Desktop\PHD\Projects\MY_MODELS\TCOPredictor\elecond_trainer.py", line 21, in <module>
df = stc.featurize_dataframe(df, 'formula', ignore_errors = True)
File "C:\Users\hp\anaconda3\envs\MLforChemistry\lib\site-packages\matminer\featurizers\conversions.py", line 90, in featurize_dataframe
return super().featurize_dataframe(df, col_id, **kwargs)
File "C:\Users\hp\anaconda3\envs\MLforChemistry\lib\site-packages\matminer\featurizers\base.py", line 339, in featurize_dataframe
features = self.featurize_many(
File "C:\Users\hp\anaconda3\envs\MLforChemistry\lib\site-packages\matminer\featurizers\base.py", line 465, in featurize_many
with Pool(self.n_jobs) as p:
File "C:\Users\hp\anaconda3\envs\MLforChemistry\lib\multiprocessing\context.py", line 119, in Pool
return Pool(processes, initializer, initargs, maxtasksperchild,
File "C:\Users\hp\anaconda3\envs\MLforChemistry\lib\multiprocessing\pool.py", line 212, in __init__
self._repopulate_pool()
File "C:\Users\hp\anaconda3\envs\MLforChemistry\lib\multiprocessing\pool.py", line 303, in _repopulate_pool
return self._repopulate_pool_static(self._ctx, self.Process,
File "C:\Users\hp\anaconda3\envs\MLforChemistry\lib\multiprocessing\pool.py", line 326, in _repopulate_pool_static
w.start()
File "C:\Users\hp\anaconda3\envs\MLforChemistry\lib\multiprocessing\process.py", line 121, in start
self._popen = self._Popen(self)
File "C:\Users\hp\anaconda3\envs\MLforChemistry\lib\multiprocessing\context.py", line 327, in _Popen
return Popen(process_obj)
File "C:\Users\hp\anaconda3\envs\MLforChemistry\lib\multiprocessing\popen_spawn_win32.py", line 45, in __init__
prep_data = spawn.get_preparation_data(process_obj._name)
File "C:\Users\hp\anaconda3\envs\MLforChemistry\lib\multiprocessing\spawn.py", line 154, in get_preparation_data
_check_not_importing_main()
File "C:\Users\hp\anaconda3\envs\MLforChemistry\lib\multiprocessing\spawn.py", line 134, 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.
StrToComposition: 0%| | 0/6229 [00:00<?, ?it/s]