rstudio / reticulate

R Interface to Python
https://rstudio.github.io/reticulate
Apache License 2.0
1.67k stars 327 forks source link

n_jobs > 1 in sklearn causes model fit to hang indefinitely, but only in Rstudio using reticulate #517

Open ryankarel opened 5 years ago

ryankarel commented 5 years ago

Here's the code I'm using:

import numpy as np
from sklearn.ensemble import RandomForestRegressor
from sklearn.model_selection import RandomizedSearchCV
import time

X = np.random.randn(1000 * 20).reshape(1000,20)
y = np.random.randn(1000)

# not specifying n_jobs
rf = RandomForestRegressor()

n_estimators = [5,10]
max_features = ['sqrt']

random_grid = {'n_estimators': n_estimators,
               'max_features': max_features}

rf_random = RandomizedSearchCV(estimator=rf, param_distributions=random_grid,
                               n_iter=2, cv=3)

tic = time.perf_counter()

rf_random.fit(X,y)

toc = time.perf_counter()

"Time required to fit RF: {0:.1f} s".format(toc - tic)
# 0.2 seconds

# specifying n_jobs == 2
rf = RandomForestRegressor()

n_estimators = [5,10]
max_features = ['sqrt']

random_grid = {'n_estimators': n_estimators,
               'max_features': max_features}

rf_random = RandomizedSearchCV(estimator=rf, param_distributions=random_grid,
                               n_iter=2, cv=3, n_jobs=2, pre_dispatch=2)

tic = time.perf_counter()

rf_random.fit(X,y)

toc = time.perf_counter()

"Time required to fit RF: {0:.1f} s".format(toc - tic)
# never finishes in Rstudio using reticulate,
# but finishes in 2.0 seconds using Spyder

When I try to knit an RMD file with the above python code chunk, a terminal window appears with the text:

WARNING: unknown option '-c'
WARNING: unknown option '--multiprocessing-fork'

Here's my (abbreviated) py_config() output:

python:         C:\Users\nkarel\AppData\Local\CONTIN~1\ANACON~2\python.exe
libpython:      C:/Users/nkarel/AppData/Local/CONTIN~1/ANACON~2/python37.dll
pythonhome:     C:\Users\nkarel\AppData\Local\CONTIN~1\ANACON~2
version:        3.7.0 (default, Jun 28 2018, 08:04:48) [MSC v.1912 64 bit (AMD64)]
Architecture:   64bit
numpy:          C:\Users\nkarel\AppData\Local\CONTIN~1\ANACON~2\lib\site-packages\numpy
numpy_version:  1.15.4

As mentioned above, running the python script in a Python IDE works perfectly, but running it using the reticulate package with Rstudio results in an indefinitely hanging process. Is reticulate not meant to run multiple jobs, or is this a bug?

ryankarel commented 5 years ago

I should also mention that I'm using Windows 10.

ercbk commented 4 years ago

In issue 134 @jjallaire thinks it may be a problem with multiprocessing and embedded python interpreters, but that was back in 2017. Really surprised this problem isn't mentioned anywhere in the documentation or this issue hasn't received a response. Kind of a big deal.

kevinushey commented 4 years ago

For this particular issue, the problem is that sys$executable and sys$_base_executable do not point at the expected things for joblib:

library(reticulate)
sys <- import("sys")
print(sys$executable)
## [1] "C:\\R\\R-36~1.1\\bin\\x64\\Rterm.exe"
print(sys$`_base_executable`)
## [1] "C:\\R\\R-36~1.1\\bin\\x64\\Rterm.exe"

I think we need to set these to the path to the Python interpreter for multiprocessing modules / joblib to work as expected.

skeydan commented 4 years ago

(((Aside question, is this expected to be a Windows-only problem? For me the above code works fine under Linux. But for me, sys$executable (https://github.com/rstudio/reticulate/blob/9dedfb3fa043ed5f035d6a1ee162cc9ee3b1c64e/R/repl.R#L265) points to Python, not R...)))

ercbk commented 4 years ago

I think I'm encountering the same issue, but I'm just using a R script and not trying to source and knit a Rmd. So, I'll add my error report to the mix in case it helps any. Btw if there's a hack to get around this in the meantime, I'd appreciate that. Thank you

pacman::p_load(dials, reticulate)

sk_e <- import("sklearn.ensemble")
sk_ms <- import("sklearn.model_selection")

sim_data <- function(n) {
      tmp <- mlbench::mlbench.friedman1(n, sd=1)
      tmp <- cbind(tmp$x, tmp$y)
      tmp <- as.data.frame(tmp)
      names(tmp)[ncol(tmp)] <- "y"
      tmp
}

dat <- sim_data(10000)

pdat = r_to_py(dat)

y = pdat$pop('y')$values
X <- pdat

rf_est <- sk_e$RandomForestRegressor(criterion = "mae", random_state = 1L)
# rf_est <- sk_e$RandomForestRegressor(criterion = "mae", n_jobs = -1L, random_state = 1L)

rf_params <- r_to_py(dials::grid_latin_hypercube(
      mtry(range = c(3, 4)),
      trees(range = c(200, 300)),
      size = 40
))
max_features <- rf_params$pop('mtry')$values
n_estimators <- rf_params$pop('trees')$values
rf_grid <- py_dict(list('max_features', 'n_estimators'), list(max_features, n_estimators))

cv <- sk_ms$RepeatedKFold(n_splits = 2L,
                          n_repeats = 2L,
                          random_state = 1L)

mod_select <- sk_ms$GridSearchCV(estimator = rf_est,
                                 param_grid = rf_grid,
                                 scoring = 'neg_mean_absolute_error',
                                 cv = cv,
                                 n_jobs = -1L,
                                 refit = TRUE)

results <- mod_select$fit(X, y)
#> Error in py_call_impl(callable, dots$args, dots$keywords): OSError: [Errno 22] Invalid argument
#> 
#> Detailed traceback: 
#>   File "C:\Users\tbats\Miniconda3\lib\site-packages\sklearn\model_selection\_search.py", line 710, in fit
#>     self._run_search(evaluate_candidates)
#>   File "C:\Users\tbats\Miniconda3\lib\site-packages\sklearn\model_selection\_search.py", line 1151, in _run_search
#>     evaluate_candidates(ParameterGrid(self.param_grid))
#>   File "C:\Users\tbats\Miniconda3\lib\site-packages\sklearn\model_selection\_search.py", line 689, in evaluate_candidates
#>     cv.split(X, y, groups)))
#>   File "C:\Users\tbats\Miniconda3\lib\site-packages\joblib\parallel.py", line 1004, in __call__
#>     if self.dispatch_one_batch(iterator):
#>   File "C:\Users\tbats\Miniconda3\lib\site-packages\joblib\parallel.py", line 835, in dispatch_one_batch
#>     self._dispatch(tasks)
#>   File "C:\Users\tbats\Miniconda3\lib\site-packages\joblib\parallel.py", line 754, in _dispatch
#>     job = self._backend.apply_async(batch, callback=cb)
#>   File "C:\Users\tbats\Miniconda3\lib\site-packages\joblib\_parallel_backends.py", line 551, in apply_async
#>     future = self._workers.submit(SafeFunction(func))
#>   File "C:\Users\tbats\Miniconda3\lib\site-packages\joblib\externals\loky\reusable_executor.py", line 160, in submit
#>     fn, *args, **kwargs)
#>   File "C:\Users\tbats\Miniconda3\lib\site-packages\joblib\externals\loky\process_executor.py", line 1047, in submit
#>     self._ensure_executor_running()
#>   File "C:\Users\tbats\Miniconda3\lib\site-packages\joblib\externals\loky\process_executor.py", line 1021, in _ensure_executor_running
#>     self._adjust_process_count()
#>   File "C:\Users\tbats\Miniconda3\lib\site-packages\joblib\externals\loky\process_executor.py", line 1012, in _adjust_process_count
#>     p.start()
#>   File "C:\Users\tbats\Miniconda3\lib\multiprocessing\process.py", line 112, in start
#>     self._popen = self._Popen(self)
#>   File "C:\Users\tbats\Miniconda3\lib\site-packages\joblib\externals\loky\backend\process.py", line 39, in _Popen
#>     return Popen(process_obj)
#>   File "C:\Users\tbats\Miniconda3\lib\site-packages\joblib\externals\loky\backend\popen_loky_win32.py", line 55, in __init__
#>     process_obj._name, getattr(process_obj, "init_main_module", True))
#>   File "C:\Users\tbats\Miniconda3\lib\site-packages\joblib\externals\loky\backend\spawn.py", line 86, in get_preparation_data
#>     _resource_tracker.ensure_running()
#>   File "C:\Users\tbats\Miniconda3\lib\site-packages\joblib\externals\loky\backend\resource_tracker.py", line 83, in ensure_running
#>     if self._check_alive():
#>   File "C:\Users\tbats\Miniconda3\lib\site-packages\joblib\externals\loky\backend\resource_tracker.py", line 163, in _check_alive
#>     self._send('PROBE', '', '')
#>   File "C:\Users\tbats\Miniconda3\lib\site-packages\joblib\externals\loky\backend\resource_tracker.py", line 185, in _send
#>     nbytes = os.write(self._fd, msg)

Created on 2020-01-30 by the reprex package (v0.3.0)

current session info ```r - Session info -------------------------------------------------- setting value version R version 3.6.2 (2019-12-12) os Windows 10 x64 system x86_64, mingw32 ui RStudio language (EN) collate English_United States.1252 ctype English_United States.1252 tz America/New_York date 2020-01-30 - Packages ------------------------------------------------------ package * version date lib source assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.6.1) backports 1.1.5 2019-10-02 [1] CRAN (R 3.6.1) callr 3.4.0 2019-12-09 [1] CRAN (R 3.6.2) cli 2.0.1 2020-01-08 [1] CRAN (R 3.6.2) clipr 0.7.0 2019-07-23 [1] CRAN (R 3.6.1) colorspace 1.4-1 2019-03-18 [1] CRAN (R 3.6.1) crayon 1.3.4 2017-09-16 [1] CRAN (R 3.6.1) desc 1.2.0 2018-05-01 [1] CRAN (R 3.6.1) details * 0.2.1 2020-01-12 [1] CRAN (R 3.6.2) dials * 0.0.4 2019-12-02 [1] CRAN (R 3.6.2) DiceDesign 1.8-1 2019-07-31 [1] CRAN (R 3.6.1) digest 0.6.23 2019-11-23 [1] CRAN (R 3.6.2) dplyr 0.8.3 2019-07-04 [1] CRAN (R 3.6.1) evaluate 0.14 2019-05-28 [1] CRAN (R 3.6.1) fansi 0.4.1 2020-01-08 [1] CRAN (R 3.6.2) fs 1.3.1 2019-05-06 [1] CRAN (R 3.6.1) glue 1.3.1 2019-03-12 [1] CRAN (R 3.6.1) htmltools 0.4.0 2019-10-04 [1] CRAN (R 3.6.1) httr 1.4.1 2019-08-05 [1] CRAN (R 3.6.1) jsonlite 1.6 2018-12-07 [1] CRAN (R 3.6.1) knitr 1.27 2020-01-16 [1] CRAN (R 3.6.2) lifecycle 0.1.0 2019-08-01 [1] CRAN (R 3.6.1) magrittr 1.5 2014-11-22 [1] CRAN (R 3.6.1) munsell 0.5.0 2018-06-12 [1] CRAN (R 3.6.1) pacman 0.5.1 2019-03-11 [1] CRAN (R 3.6.1) pillar 1.4.3 2019-12-20 [1] CRAN (R 3.6.2) pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 3.6.1) png 0.1-7 2013-12-03 [1] CRAN (R 3.6.0) processx 3.4.1 2019-07-18 [1] CRAN (R 3.6.1) ps 1.3.0 2018-12-21 [1] CRAN (R 3.6.1) purrr 0.3.3 2019-10-18 [1] CRAN (R 3.6.2) R6 2.4.1 2019-11-12 [1] CRAN (R 3.6.2) rappdirs 0.3.1 2016-03-28 [1] CRAN (R 3.6.1) Rcpp 1.0.3 2019-11-08 [1] CRAN (R 3.6.2) reprex 0.3.0 2019-05-16 [1] CRAN (R 3.6.1) reticulate * 1.14 2019-12-17 [1] CRAN (R 3.6.2) rlang 0.4.2 2019-11-23 [1] CRAN (R 3.6.2) rmarkdown 2.1 2020-01-20 [1] CRAN (R 3.6.2) rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.6.1) rstudioapi 0.10 2019-03-19 [1] CRAN (R 3.6.1) scales * 1.1.0 2019-11-18 [1] CRAN (R 3.6.2) sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.6.1) tibble 2.1.3 2019-06-06 [1] CRAN (R 3.6.1) tidyselect 0.2.5 2018-10-11 [1] CRAN (R 3.6.1) whisker 0.4 2019-08-28 [1] CRAN (R 3.6.1) withr 2.1.2 2018-03-15 [1] CRAN (R 3.6.1) xfun 0.12 2020-01-13 [1] CRAN (R 3.6.2) xml2 1.2.2 2019-08-09 [1] CRAN (R 3.6.1) [1] C:/Users/tbats/Documents/R/win-library/3.6 [2] C:/Program Files/R/R-3.6.2/library python: C:/Users/tbats/Miniconda3/python.exe libpython: C:/Users/tbats/Miniconda3/python37.dll pythonhome: C:/Users/tbats/Miniconda3 version: 3.7.4 (default, Aug 9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)] Architecture: 64bit numpy: C:/Users/tbats/Miniconda3/Lib/site-packages/numpy numpy_version: 1.18.1 sklearn: C:\Users\tbats\MINICO~1\lib\site-packages\sklearn\__init__.p # packages in environment at C:\Users\tbats\Miniconda3: # # Name Version Build Channel asn1crypto 1.3.0 py37_0 blas 1.0 mkl ca-certificates 2019.11.27 0 certifi 2019.11.28 py37_0 cffi 1.13.2 py37h7a1dbc1_0 chardet 3.0.4 py37_1003 conda 4.8.1 py37_0 conda-package-handling 1.6.0 py37h62dcd97_0 console_shortcut 0.1.1 3 cryptography 2.8 py37h7a1dbc1_0 icc_rt 2019.0.0 h0cc432a_1 idna 2.8 py37_0 intel-openmp 2019.4 245 joblib 0.14.1 py_0 menuinst 1.4.16 py37he774522_0 mkl 2019.4 245 mkl-service 2.3.0 py37hb782905_0 mkl_fft 1.0.15 py37h14836fe_0 mkl_random 1.1.0 py37h675688f_0 numpy 1.18.1 py37h93ca92e_0 numpy-base 1.18.1 py37hc3f5095_1 openssl 1.1.1d he774522_3 pandas 0.25.3 py37ha925a31_0 pip 19.3.1 py37_0 powershell_shortcut 0.0.1 2 pycosat 0.6.3 py37he774522_0 pycparser 2.19 py37_0 pyopenssl 19.1.0 py37_0 pysocks 1.7.1 py37_0 python 3.7.4 h5263a28_0 python-dateutil 2.8.1 py_0 pytz 2019.3 py_0 pywin32 227 py37he774522_1 requests 2.22.0 py37_1 ruamel_yaml 0.15.87 py37he774522_0 scikit-learn 0.22.1 py37h6288b17_0 scipy 1.3.2 py37h29ff71c_0 setuptools 44.0.0 py37_0 six 1.13.0 py37_0 sqlite 3.30.1 he774522_0 tqdm 4.41.1 py_0 urllib3 1.25.7 py37_0 vc 14.1 h0510ff6_4 vs2015_runtime 14.16.27012 hf0eaf9b_1 wheel 0.33.6 py37_0 win_inet_pton 1.1.0 py37_0 wincertstore 0.2 py37_0 yaml 0.1.7 hc54c509_2 ```


kevinushey commented 4 years ago

What worked for me was to re-assign those values in the sys and multiprocessing modules. That is, you can try running this at the top of your script (before importing any other modules):

library(reticulate)

# update executable path in sys module
sys <- import("sys")
exe <- file.path(sys$exec_prefix, "pythonw.exe")
sys$executable <- exe
sys$`_base_executable` <- exe

# update executable path in multiprocessing module
multiprocessing <- import("multiprocessing")
multiprocessing$set_executable(exe)
ercbk commented 4 years ago

Worked! Thanks again. One more question - will the pythonw.exe instances eventually end on their own or should I terminate them? I had to end the first session I tried this, and those pythonw.exe instances are still around along with the ones from this second run.

Nevermind. They ended when I quit RStudio.

kevinushey commented 4 years ago

Yes indeed, they'll exit when the R session is shut down. (I'm not sure whether Python tries to re-use the existing child sessions, or if they should normally be shut down after running the requisite code, though.)

ercbk commented 4 years ago

Ran a similar script overnight through RScript.exe. It's been over 3.5 hrs since the job finished, and the python instances didn't terminate. So, I guess these might need to be shut down.

vermosen commented 3 years ago

Hi,

I see a similar problem in centos 8 using both base R and Rstudio. Consider the following Rscript:

library(reticulate)

use_condaenv(condaenv = 'py38', conda = '/opt/miniconda/bin/conda')

sk        <- NULL
sk$ds  <- import("sklearn.datasets")
sk$ms <- import("sklearn.model_selection")
sk$da  <- import("sklearn.discriminant_analysis")

# define dataset
data <- sk$ds$make_classification(n_samples=1000L, n_features=10L, n_informative=10L, n_redundant=0L, random_state=1L)

# define model
model <- sk$da$LinearDiscriminantAnalysis()

# define model evaluation method
cv <- sk$ms$RepeatedStratifiedKFold(n_splits=10L, n_repeats=3L, random_state=1L)

# evaluate the model
scores <- sk$ms$cross_val_score(model, data[[1]], data[[2]]
                      , scoring='accuracy', cv=cv, n_jobs=2L)

# Error: C stack usage  331680283904 is too close to the limit
cat('score: ', score)

as soon the n_jobs value create forks (i.e. n_jobs != 1), the R session crashes on the last line with the message above. Also, I end up with stuck python processes I have to kill manually.

I checked the executable and _base_executable values mentioned and there are both set to the correct python binary.

Here is my R setup:

R version 4.0.3 (2020-10-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 8

Matrix products: default
BLAS/LAPACK: /opt/r40/lib64/libopenblas.so.0.3

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] reticulate_1.18

loaded via a namespace (and not attached):
[1] compiler_4.0.3  Matrix_1.2-18   Rcpp_1.0.5      grid_4.0.3
[5] jsonlite_1.7.1  lattice_0.20-41
my miniconda env ``` name: py38 channels: - conda-forge - defaults dependencies: - _libgcc_mutex=0.1=main - alabaster=0.7.12=py_0 - attrs=20.3.0=pyhd3eb1b0_0 - automat=20.2.0=py_0 - babel=2.8.0=py_0 - bcrypt=3.2.0=py38h7b6447c_0 - beautifulsoup4=4.9.3=pyhb0f4dca_0 - binutils_impl_linux-64=2.33.1=he6710b0_7 - binutils_linux-64=2.33.1=h9595d00_15 - blas=1.0=mkl - bottle=0.12.18=py_0 - brotlipy=0.7.0=py38h8df0ef7_1001 - bs4=4.9.3=0 - ca-certificates=2020.12.8=h06a4308_0 - certifi=2020.12.5=py38h06a4308_0 - cffi=1.14.3=py38he30daa8_0 - chardet=3.0.4=py38h924ce5b_1008 - click=7.1.2=py_0 - colorama=0.4.4=pyh9f0ad1d_0 - conan=1.31.0=pyhd3deb0d_0 - - constantly=15.1.0=py_0 - cryptography=3.2.1=py38h7699a38_0 - cssselect=1.1.0=py_0 - cycler=0.10.0=py38_0 - cython=0.29.21=py38h2531618_0 - dbus=1.13.18=hb2f20db_0 - deprecation=2.0.6=py_0 - distro=1.5.0=pyh9f0ad1d_0 - docutils=0.16=py38_1 - expat=2.2.10=he6710b0_2 - fasteners=0.14.1=py_3 - flake8=3.8.4=py_0 - flask=1.1.2=py_0 - fontconfig=2.13.0=h9420a91_0 - freetype=2.10.4=h5ab3b9f_0 - future=0.18.2=py38h32f6830_2 - gcc_impl_linux-64=7.3.0=habb00fd_1 - gcc_linux-64=7.3.0=h553295d_15 - glib=2.66.1=h92f7085_0 - gst-plugins-base=1.14.0=hbbd80ab_1 - gstreamer=1.14.0=hb31296c_0 - gxx_impl_linux-64=7.3.0=hdf63c60_1 - gxx_linux-64=7.3.0=h553295d_15 - hyperlink=20.0.1=py_0 - icu=58.2=he6710b0_3 - idna=2.10=pyh9f0ad1d_0 - imagesize=1.2.0=py_0 - importlib-metadata=2.0.0=py_1 - incremental=17.5.0=py38_0 - iniconfig=1.1.1=py_0 - intel-openmp=2020.2=254 - itemadapter=0.2.0=pyhd3eb1b0_0 - itsdangerous=1.1.0=py_0 - jinja2=2.11.2=pyh9f0ad1d_0 - joblib=0.17.0=py_0 - jpeg=9b=h024ee3a_2 - kiwisolver=1.3.0=py38h2531618_0 - lcms2=2.11=h396b838_0 - ld_impl_linux-64=2.33.1=h53a641e_7 - libedit=3.1.20191231=h14c3975_1 - libffi=3.3=he6710b0_2 - libgcc-ng=9.1.0=hdf63c60_0 - libgfortran-ng=7.3.0=hdf63c60_0 - libpng=1.6.37=hbc83047_0 - libstdcxx-ng=9.1.0=hdf63c60_0 - libtiff=4.1.0=h2733197_1 - libuuid=1.0.3=h1bed415_2 - libxcb=1.14=h7b6447c_0 - libxml2=2.9.10=hb55368b_3 - libxslt=1.1.34=hc22bd24_0 - lxml=4.6.2=py38h9120a33_0 - lz4-c=1.9.2=heb0550a_3 - markupsafe=1.1.1=py38h8df0ef7_2 - matplotlib=3.3.2=0 - matplotlib-base=3.3.2=py38h817c723_0 - mccabe=0.6.1=py38_1 - mkl=2020.2=256 - mkl-service=2.3.0=py38he904b0f_0 - mkl_fft=1.2.0=py38h23d657b_0 - mkl_random=1.1.1=py38h0573a6f_0 - monotonic=1.5=py_0 - more-itertools=8.6.0=pyhd3eb1b0_0 - ncurses=6.2=he6710b0_1 - numpy=1.19.2=py38h54aff64_0 - numpy-base=1.19.2=py38hfa32c7d_0 - olefile=0.46=py_0 - openssl=1.1.1i=h27cfd23_0 - packaging=20.4=pyh9f0ad1d_0 - pandas=1.1.3=py38he6710b0_0 - parsel=1.5.2=py38_0 - patch-ng=1.17.4=pyh9f0ad1d_0 - pcre=8.44=he6710b0_0 - pillow=8.0.1=py38he98fc37_0 - pip=20.2.4=py38h06a4308_0 - plotly=4.14.1=pyhd3eb1b0_0 - pluggy=0.13.1=py38_0 - pluginbase=1.0.0=py_0 - py=1.9.0=py_0 - pyasn1=0.4.8=py_0 - pyasn1-modules=0.2.8=py_0 - pycodestyle=2.6.0=py_0 - pycparser=2.20=pyh9f0ad1d_2 - pydispatcher=2.0.5=py38_1 - pyflakes=2.2.0=py_0 - pygments=2.7.2=py_0 - pyhamcrest=2.0.2=py_0 - pyjwt=1.7.1=py_0 - pyopenssl=19.1.0=py_1 - pyparsing=2.4.7=pyh9f0ad1d_0 - pyqt=5.9.2=py38h05f1152_4 - pysocks=1.7.1=py38h924ce5b_2 - pystan=2.18.0.0=py38h962f231_0 - pytest=6.1.2=py38h06a4308_0 - pytest-runner=5.2=py_0 - python=3.8.5=h7579374_1 - python-dateutil=2.8.1=py_0 - python-node-semver=0.6.1=py_0 - python_abi=3.8=1_cp38 - pytz=2020.1=py_0 - pywavelets=1.1.1=py38h7b6447c_2 - pyyaml=5.3.1=py38h8df0ef7_1 - qt=5.9.7=h5867ecd_1 - queuelib=1.5.0=py38_0 - readline=8.0=h7b6447c_0 - requests=2.25.0=pyhd3eb1b0_0 - retrying=1.3.3=py_2 - scikit-learn=0.23.2=py38h0573a6f_0 - scipy=1.5.2=py38h0b6359f_0 - scrapy=2.4.0=py38_0 - service_identity=18.1.0=py_0 - setuptools=50.3.0=py38h06a4308_1 - sip=4.19.13=py38he6710b0_0 - six=1.15.0=py_0 - snowballstemmer=2.0.0=py_0 - soupsieve=2.0.1=py_0 - sphinx=3.2.1=py_0 - sphinxcontrib-applehelp=1.0.2=py_0 - sphinxcontrib-devhelp=1.0.2=py_0 - sphinxcontrib-htmlhelp=1.0.3=py_0 - sphinxcontrib-jsmath=1.0.1=py_0 - sphinxcontrib-qthelp=1.0.3=py_0 - sphinxcontrib-serializinghtml=1.1.4=py_0 - sqlalchemy=1.3.20=py38h7b6447c_0 - sqlite=3.33.0=h62c20be_0 - threadpoolctl=2.1.0=pyh5ca1d4c_0 - tk=8.6.10=hbc83047_0 - toml=0.10.1=py_0 - tornado=6.0.4=py38h7b6447c_1 - tqdm=4.51.0=pyh9f0ad1d_0 - twisted=20.3.0=py38h7b6447c_0 - urllib3=1.25.11=py_0 - w3lib=1.21.0=py_0 - werkzeug=1.0.1=py_0 - wheel=0.35.1=py_0 - xz=5.2.5=h7b6447c_0 - yaml=0.2.5=h516909a_0 - zipp=3.4.0=pyhd3eb1b0_0 - zlib=1.2.11=h7b6447c_3 - zope=1.0=py38_1 - zope.interface=5.1.2=py38h7b6447c_0 - zstd=1.4.5=h9ceee32_0 - pip: - quantlib==1.20 - quantlib-python==1.18 prefix: /opt/miniconda/envs/py38 ```
shivam7898 commented 2 years ago

Reiterating this comment above, because it took me sometime, to do the same in a Python chunk or file in Windows 10

import sys, os, multiprocessing
q_EXE_PATH = os.path.join(sys.exec_prefix, 'pythonw.exe')
sys.executable = q_EXE_PATH
sys._base_executable = q_EXE_PATH
multiprocessing.set_executable(q_EXE_PATH)