py-why / EconML

ALICE (Automated Learning and Intelligence for Causation and Economics) is a Microsoft Research project aimed at applying Artificial Intelligence concepts to economic decision making. One of its goals is to build a toolkit that combines state-of-the-art machine learning techniques with econometrics in order to bring automation to complex causal inference problems. To date, the ALICE Python SDK (econml) implements orthogonal machine learning algorithms such as the double machine learning work of Chernozhukov et al. This toolkit is designed to measure the causal effect of some treatment variable(s) t on an outcome variable y, controlling for a set of features x.
https://www.microsoft.com/en-us/research/project/alice/
Other
3.84k stars 718 forks source link

Converting to Python object not allowed without gil #871

Open forestqin opened 7 months ago

forestqin commented 7 months ago

Please HELP....thanks a lot!

I would like to install EconML by locally compiling mode

envs: OS: windows10 python:3.11

steps: 1) git clone from github by : git clone git@github.com:py-why/EconML.git 2) cd EconML 3) install: pip install --no-build-isolation --editable .

but, a error occurred like:

Error compiling Cython file:

          dlacpy(UPLO, &lda, &n, a, &lda, a_copy, &lda)
          if copy_b:
              dlacpy(UPLO, &ldb, &nrhs, b, &ldb, b_copy, &ldb)

          dgelsy(&m, &n, &nrhs, a_copy, &lda, b_copy, &ldb,
                 &jpvt[0], &rcond, &rank, &work[0], &lwork, &info)
                                                            ^
  ------------------------------------------------------------

  **econml\grf\_utils.pyx:141:58: Converting to Python object not allowed without gil**
  Warning: Multiple cython sources found for extension '*': ['econml\\grf\\_criterion.pyx', 'econml\\grf\\_utils.pyx', 'econml\\policy\\_forest\\_criterion.pyx', 'econml\\tree\\_criterion.pyx', 'econml\\tree\\_splitter.pyx', 'econml\\tree\\_tree.pyx', 'econml\\tree\\_utils.pyx']
  See https://cython.readthedocs.io/en/latest/src/userguide/sharing_declarations.html for sharing declarations among Cython files.
  Compiling econml\grf\_criterion.pyx because it changed.
  Compiling econml\grf\_utils.pyx because it changed.
  Compiling econml\policy\_forest\_criterion.pyx because it changed.
  Compiling econml\tree\_criterion.pyx because it changed.
  Compiling econml\tree\_splitter.pyx because it changed.
  Compiling econml\tree\_tree.pyx because it changed.
  Compiling econml\tree\_utils.pyx because it changed.
  [1/7] Cythonizing econml\grf\_criterion.pyx
  [2/7] Cythonizing econml\grf\_utils.pyx
  Traceback (most recent call last):
    File "C:\Users\Admin\miniconda3\envs\econml\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
      main()
    File "C:\Users\Admin\miniconda3\envs\econml\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Admin\miniconda3\envs\econml\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 181, in prepare_metadata_for_build_editable
      return hook(metadata_directory, config_settings)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Admin\miniconda3\envs\econml\Lib\site-packages\setuptools\build_meta.py", line 473, in prepare_metadata_for_build_editable
      return self.prepare_metadata_for_build_wheel(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\Admin\miniconda3\envs\econml\Lib\site-packages\setuptools\build_meta.py", line 396, in prepare_metadata_for_build_wheel
      self.run_setup()
    File "C:\Users\Admin\miniconda3\envs\econml\Lib\site-packages\setuptools\build_meta.py", line 341, in run_setup
      exec(code, locals())
    File "<string>", line 28, in <module>
    File "C:\Users\Admin\miniconda3\envs\econml\Lib\site-packages\Cython\Build\Dependencies.py", line 1154, in cythonize
      cythonize_one(*args)
    File "C:\Users\Admin\miniconda3\envs\econml\Lib\site-packages\Cython\Build\Dependencies.py", line 1321, in cythonize_one
      raise CompileError(None, pyx_file)
  Cython.Compiler.Errors.CompileError: econml\grf\_utils.pyx

could anyone help me for this issue? thanks a lot

kbattocchi commented 7 months ago

Hard to say what might be going wrong, but as a first step, maybe don't use the --no-build-isolation flag - it's possible you've already got a version of some package installed that would otherwise use a different version during build.