uber / causalml

Uplift modeling and causal inference with machine learning algorithms
Other
5.08k stars 780 forks source link

Error while installing `causalml` @ Windows 10 #315

Closed AlxndrMlk closed 3 years ago

AlxndrMlk commented 3 years ago

Describe the bug I am trying to install causalml on Windows 10. I get the following error:

    ERROR: Command errored out with exit status 1:
     command: 'C:\Users\user1\AppData\Local\Continuum\anaconda3\envs\uplift-env\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\user1\\AppData\\Local\\Temp\\pip-install-loistf62\\causalml_2c0f30e248f54d2a83b42c6d25e74d0a\\setup.py'"'"'; __file__='"'"'C:\\Users\\user1\\AppData\\Local\\Temp\\pip-install-loistf62\\causalml_2c0f30e248f54d2a83b42c6d25e74d0a\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\user1\AppData\Local\Temp\pip-record-4kb5f8h7\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\user1\AppData\Local\Continuum\anaconda3\envs\uplift-env\Include\causalml'
         cwd: C:\Users\user1\AppData\Local\Temp\pip-install-loistf62\causalml_2c0f30e248f54d2a83b42c6d25e74d0a\
    Complete output (89 lines):
    Compiling causalml/inference/tree/causaltree.pyx because it depends on C:\Users\user1\AppData\Local\Continuum\anaconda3\envs\uplift-env\lib\site-packages\Cython\Includes\numpy\__init__.pxd.
    [1/1] Cythonizing causalml/inference/tree/causaltree.pyx
    C:\Users\user1\AppData\Local\Continuum\anaconda3\envs\uplift-env\lib\site-packages\Cython\Compiler\Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: C:\Users\user1\AppData\Local\Temp\pip-install-loistf62\causalml_2c0f30e248f54d2a83b42c6d25e74d0a\causalml\inference\tree\causaltree.pyx
          tree = Parsing.p_module(s, pxd, full_module_name)
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.8
    creating build\lib.win-amd64-3.8\causalml
    copying causalml\features.py -> build\lib.win-amd64-3.8\causalml
    copying causalml\match.py -> build\lib.win-amd64-3.8\causalml
    copying causalml\propensity.py -> build\lib.win-amd64-3.8\causalml
    copying causalml\__init__.py -> build\lib.win-amd64-3.8\causalml
    creating build\lib.win-amd64-3.8\tests
    copying tests\conftest.py -> build\lib.win-amd64-3.8\tests
    copying tests\const.py -> build\lib.win-amd64-3.8\tests
    copying tests\test_cevae.py -> build\lib.win-amd64-3.8\tests
    copying tests\test_counterfactual_unit_selection.py -> build\lib.win-amd64-3.8\tests
    copying tests\test_datasets.py -> build\lib.win-amd64-3.8\tests
    copying tests\test_features.py -> build\lib.win-amd64-3.8\tests
    copying tests\test_ivlearner.py -> build\lib.win-amd64-3.8\tests
    copying tests\test_match.py -> build\lib.win-amd64-3.8\tests
    copying tests\test_meta_learners.py -> build\lib.win-amd64-3.8\tests
    copying tests\test_propensity.py -> build\lib.win-amd64-3.8\tests
    copying tests\test_sensitivity.py -> build\lib.win-amd64-3.8\tests
    copying tests\test_uplift_trees.py -> build\lib.win-amd64-3.8\tests
    copying tests\test_value_optimization.py -> build\lib.win-amd64-3.8\tests
    copying tests\__init__.py -> build\lib.win-amd64-3.8\tests
    creating build\lib.win-amd64-3.8\causalml\dataset
    copying causalml\dataset\classification.py -> build\lib.win-amd64-3.8\causalml\dataset
    copying causalml\dataset\regression.py -> build\lib.win-amd64-3.8\causalml\dataset
    copying causalml\dataset\synthetic.py -> build\lib.win-amd64-3.8\causalml\dataset
    copying causalml\dataset\__init__.py -> build\lib.win-amd64-3.8\causalml\dataset
    creating build\lib.win-amd64-3.8\causalml\feature_selection
    copying causalml\feature_selection\filters.py -> build\lib.win-amd64-3.8\causalml\feature_selection
    copying causalml\feature_selection\__init__.py -> build\lib.win-amd64-3.8\causalml\feature_selection
    creating build\lib.win-amd64-3.8\causalml\inference
    copying causalml\inference\__init__.py -> build\lib.win-amd64-3.8\causalml\inference
    creating build\lib.win-amd64-3.8\causalml\metrics
    copying causalml\metrics\classification.py -> build\lib.win-amd64-3.8\causalml\metrics
    copying causalml\metrics\const.py -> build\lib.win-amd64-3.8\causalml\metrics
    copying causalml\metrics\regression.py -> build\lib.win-amd64-3.8\causalml\metrics
    copying causalml\metrics\sensitivity.py -> build\lib.win-amd64-3.8\causalml\metrics
    copying causalml\metrics\visualize.py -> build\lib.win-amd64-3.8\causalml\metrics
    copying causalml\metrics\__init__.py -> build\lib.win-amd64-3.8\causalml\metrics
    creating build\lib.win-amd64-3.8\causalml\optimize
    copying causalml\optimize\policylearner.py -> build\lib.win-amd64-3.8\causalml\optimize
    copying causalml\optimize\unit_selection.py -> build\lib.win-amd64-3.8\causalml\optimize
    copying causalml\optimize\utils.py -> build\lib.win-amd64-3.8\causalml\optimize
    copying causalml\optimize\value_optimization.py -> build\lib.win-amd64-3.8\causalml\optimize
    copying causalml\optimize\__init__.py -> build\lib.win-amd64-3.8\causalml\optimize
    creating build\lib.win-amd64-3.8\causalml\inference\iv
    copying causalml\inference\iv\drivlearner.py -> build\lib.win-amd64-3.8\causalml\inference\iv
    copying causalml\inference\iv\iv_regression.py -> build\lib.win-amd64-3.8\causalml\inference\iv
    copying causalml\inference\iv\__init__.py -> build\lib.win-amd64-3.8\causalml\inference\iv
    creating build\lib.win-amd64-3.8\causalml\inference\meta
    copying causalml\inference\meta\base.py -> build\lib.win-amd64-3.8\causalml\inference\meta
    copying causalml\inference\meta\drlearner.py -> build\lib.win-amd64-3.8\causalml\inference\meta
    copying causalml\inference\meta\explainer.py -> build\lib.win-amd64-3.8\causalml\inference\meta
    copying causalml\inference\meta\rlearner.py -> build\lib.win-amd64-3.8\causalml\inference\meta
    copying causalml\inference\meta\slearner.py -> build\lib.win-amd64-3.8\causalml\inference\meta
    copying causalml\inference\meta\tlearner.py -> build\lib.win-amd64-3.8\causalml\inference\meta
    copying causalml\inference\meta\tmle.py -> build\lib.win-amd64-3.8\causalml\inference\meta
    copying causalml\inference\meta\utils.py -> build\lib.win-amd64-3.8\causalml\inference\meta
    copying causalml\inference\meta\xlearner.py -> build\lib.win-amd64-3.8\causalml\inference\meta
    copying causalml\inference\meta\__init__.py -> build\lib.win-amd64-3.8\causalml\inference\meta
    creating build\lib.win-amd64-3.8\causalml\inference\nn
    copying causalml\inference\nn\cevae.py -> build\lib.win-amd64-3.8\causalml\inference\nn
    copying causalml\inference\nn\dragonnet.py -> build\lib.win-amd64-3.8\causalml\inference\nn
    copying causalml\inference\nn\utils.py -> build\lib.win-amd64-3.8\causalml\inference\nn
    copying causalml\inference\nn\__init__.py -> build\lib.win-amd64-3.8\causalml\inference\nn
    creating build\lib.win-amd64-3.8\causalml\inference\tree
    copying causalml\inference\tree\models.py -> build\lib.win-amd64-3.8\causalml\inference\tree
    copying causalml\inference\tree\plot.py -> build\lib.win-amd64-3.8\causalml\inference\tree
    copying causalml\inference\tree\utils.py -> build\lib.win-amd64-3.8\causalml\inference\tree
    copying causalml\inference\tree\__init__.py -> build\lib.win-amd64-3.8\causalml\inference\tree
    running build_ext
    building 'causalml.inference.tree.causaltree' extension
    creating build\temp.win-amd64-3.8
    creating build\temp.win-amd64-3.8\Release
    creating build\temp.win-amd64-3.8\Release\causalml
    creating build\temp.win-amd64-3.8\Release\causalml\inference
    creating build\temp.win-amd64-3.8\Release\causalml\inference\tree
    C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29910\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Users\user1\AppData\Local\Continuum\anaconda3\envs\uplift-env\lib\site-packages\numpy\core\include -IC:\Users\user1\AppData\Local\Continuum\anaconda3\envs\uplift-env\lib\site-packages\numpy\core\include -IC:\Users\user1\AppData\Local\Continuum\anaconda3\envs\uplift-env\include -IC:\Users\user1\AppData\Local\Continuum\anaconda3\envs\uplift-env\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29910\include" /Tccausalml/inference/tree/causaltree.c /Fobuild\temp.win-amd64-3.8\Release\causalml/inference/tree/causaltree.obj -O3
    cl : Command line warning D9002 : ignoring unknown option '-O3'
    causaltree.c
    C:\Users\user1\AppData\Local\Continuum\anaconda3\envs\uplift-env\include\pyconfig.h(59): fatal error C1083: Cannot open include file: 'io.h': No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.28.29910\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\user1\AppData\Local\Continuum\anaconda3\envs\uplift-env\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\user1\\AppData\\Local\\Temp\\pip-install-loistf62\\causalml_2c0f30e248f54d2a83b42c6d25e74d0a\\setup.py'"'"'; __file__='"'"'C:\\Users\\user1\\AppData\\Local\\Temp\\pip-install-loistf62\\causalml_2c0f30e248f54d2a83b42c6d25e74d0a\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\user1\AppData\Local\Temp\pip-record-4kb5f8h7\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\user1\AppData\Local\Continuum\anaconda3\envs\uplift-env\Include\causalml' Check the logs for full command output.

To Reproduce I started with a python=3.8 conda environment and installed pip install tensorflow==2.3 before pip install causalml I tried other versions of Python as well (3.6.5, 3.7)

Environment (please complete the following information):

This part caught my attention: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2) Seems it's trying to use cython for Py2. Not sure how to address it though.

Will be grateful for any ideas. Thank you!

jeongyoonlee commented 3 years ago

Thanks for reporting this issue, @AlxndrMlk. I personally don't have access to Windows environment. Could you please try the conda environment in envs/ as follows?

$ conda env create -f environment-py38.yml
$ conda activate causalml-py38
(causalml-py38) $ python -c "import causalml; print(causalml.__version__)"

Please let me know if it works.

AlxndrMlk commented 3 years ago

Thanks @jeongyoonlee! It works! 🎉

For some reason it took a very long time to install pip dependencies, but after it finished I was able to import the lib and print the version (0.10.0)

jeongyoonlee commented 3 years ago

Glad that it worked! Have a good weekend. :)

AlxndrMlk commented 3 years ago

Thanks! Have a good one! :)