KrishnaswamyLab / TPHATE

Other
22 stars 5 forks source link

Cannot install for Python >= 3.10 #4

Open georgemsun opened 1 year ago

georgemsun commented 1 year ago

Cannot install TPHATE by pip install tphate for new installations of Python >= 3.10 in Anaconda on Windows 10. Installing by same method does work for Python 3.7, 3.8, and 3.9. Error message for pip install tphate shown below.

...
Building wheels for collected packages: scikit-learn
  Building wheel for scikit-learn (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for scikit-learn (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [56 lines of output]
      <string>:17: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
      Partial import of sklearn during the build process.
      <string>:116: DeprecationWarning:

        `numpy.distutils` is deprecated since NumPy 1.23.0, as a result
        of the deprecation of `distutils` itself. It will be removed for
        Python >= 3.12. For older Python versions it will remain present.
        It is recommended to use `setuptools < 60.0` for those Python versions.
        For more details, see:
          https://numpy.org/devdocs/reference/distutils_status_migration.html

      INFO: No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
      Traceback (most recent call last):
        File "\User\.conda\envs\tphate\lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
          main()
        File "\User\.conda\envs\tphate\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 "\User\.conda\envs\tphate\lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 251, in build_wheel
          return _build_backend().build_wheel(wheel_directory, config_settings,
        File "\User\AppData\Local\Temp\pip-build-env-goih8kgh\overlay\Lib\site-packages\setuptools\build_meta.py", line 416, in build_wheel
          return self._build_with_temp_dir(['bdist_wheel'], '.whl',
        File "\User\AppData\Local\Temp\pip-build-env-goih8kgh\overlay\Lib\site-packages\setuptools\build_meta.py", line 401, in _build_with_temp_dir
          self.run_setup()
        File "\User\AppData\Local\Temp\pip-build-env-goih8kgh\overlay\Lib\site-packages\setuptools\build_meta.py", line 487, in run_setup
          super(_BuildMetaLegacyBackend,
        File "\User\AppData\Local\Temp\pip-build-env-goih8kgh\overlay\Lib\site-packages\setuptools\build_meta.py", line 338, in run_setup
          exec(code, locals())
        File "<string>", line 306, in <module>
        File "<string>", line 302, in setup_package
        File "\User\AppData\Local\Temp\pip-build-env-goih8kgh\overlay\Lib\site-packages\numpy\distutils\core.py", line 135, in setup
          config = configuration()
        File "<string>", line 188, in configuration
        File "\User\AppData\Local\Temp\pip-build-env-goih8kgh\overlay\Lib\site-packages\numpy\distutils\misc_util.py", line 1050, in add_subpackage
          config_list = self.get_subpackage(subpackage_name, subpackage_path,
        File "\User\AppData\Local\Temp\pip-build-env-goih8kgh\overlay\Lib\site-packages\numpy\distutils\misc_util.py", line 1016, in get_subpackage
          config = self._get_configuration_from_setup_py(
        File "\User\AppData\Local\Temp\pip-build-env-goih8kgh\overlay\Lib\site-packages\numpy\distutils\misc_util.py", line 958, in _get_configuration_from_setup_py
          config = setup_module.configuration(*args)
        File "\User\AppData\Local\Temp\pip-install-1j52ic31\scikit-learn_fe2a9627b31d408c86ddc1a67a706c0f\sklearn\setup.py", line 83, in configuration
          cythonize_extensions(top_path, config)
        File "\User\AppData\Local\Temp\pip-install-1j52ic31\scikit-learn_fe2a9627b31d408c86ddc1a67a706c0f\sklearn\_build_utils\__init__.py", line 45, in cythonize_extensions
          basic_check_build()
        File "\User\AppData\Local\Temp\pip-install-1j52ic31\scikit-learn_fe2a9627b31d408c86ddc1a67a706c0f\sklearn\_build_utils\pre_build_helpers.py", line 106, in basic_check_build
          compile_test_program(code)
        File "\User\AppData\Local\Temp\pip-install-1j52ic31\scikit-learn_fe2a9627b31d408c86ddc1a67a706c0f\sklearn\_build_utils\pre_build_helpers.py", line 66, in compile_test_program
          ccompiler.compile(['test_program.c'], output_dir='objects',
        File "\User\AppData\Local\Temp\pip-build-env-goih8kgh\overlay\Lib\site-packages\setuptools\_distutils\_msvccompiler.py", line 343, in compile
          self.initialize()
        File "\User\AppData\Local\Temp\pip-build-env-goih8kgh\overlay\Lib\site-packages\setuptools\_distutils\_msvccompiler.py", line 253, in initialize
          vc_env = _get_vc_env(plat_spec)
        File "\User\AppData\Local\Temp\pip-build-env-goih8kgh\overlay\Lib\site-packages\setuptools\msvc.py", line 214, in msvc14_get_vc_env
          return _msvc14_get_vc_env(plat_spec)
        File "\User\AppData\Local\Temp\pip-build-env-goih8kgh\overlay\Lib\site-packages\setuptools\msvc.py", line 168, in _msvc14_get_vc_env
          raise distutils.errors.DistutilsPlatformError(
      distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for scikit-learn
Failed to build scikit-learn
ERROR: Could not build wheels for scikit-learn, which is required to install pyproject.toml-based projects
eloygeenjaar commented 8 months ago

I had the same issue, I was able to circumvent the issue by cloning the GitHub repo and changing the scikit-learn requirement from scikit-learn==0.24 in setup.py and pyproject.toml to >= 0.24. Furthermore, with setuptools 68>= (I haven't tried with lower versions), I had to add the following line in pyproject.toml: license = {text = "GNU General Public License Version 2"} under [project]. After that I could install the package with pip install . (while being in the TPHATE folder). Hope this helps @georgemsun, and the developers.

eloygeenjaar commented 8 months ago

Note that the reason the sklearn requirement was set at ==0.24 is because of this import in base.py: from sklearn.utils.graph import graph_shortest_path on Line 10. I think you can replace this with networkx: L10: import networkx as nx L906:

# From: https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.shortest_paths.dense.floyd_warshall_numpy.html
G = nx.from_scipy_sparse_array(D)
P = nx.floyd_warshall_numpy(G)

Instead of: P = graph_shortest_path(D, method=method)

Note this now does not take a method option anymore, but always uses the Floyd Warshall algorithm, although networkx has also implemented https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.shortest_paths.weighted.all_pairs_dijkstra_path_length.html which is more appropriate for sparse adjacency matrices, but it requires the transformation of the returned iterator into a numpy array. Another option is to use Dijkstra directly from scipy.sparse: https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csgraph.dijkstra.html These need to be tested, but I can now replicate their Jupyter notebook in TPHATE/usage/examples.ipynb