PreferredAI / cornac

A Comparative Framework for Multimodal Recommender Systems
https://cornac.preferred.ai
Apache License 2.0
845 stars 138 forks source link

Unable to Install Cornac on Mac #611

Open monuoha opened 3 months ago

monuoha commented 3 months ago

Description

Whenever I try to install cornac, several Cython files refuse to compile.

In which platform does it happen?

macOS 12.7.3

How do we replicate the issue?

Run pip install cornac in Terminal

Expected behavior (i.e. solution)

The terminal command should be able to install the cornac package with no problems.

Other Comments

darrylong commented 3 months ago

Hi @monuoha,

In order to pinpoint the issue, could you share with us the exact error?

monuoha commented 3 months ago

Example of Cython file not compiling:

Error compiling Cython file:

  ...
  from ...utils import get_rng
  from ...utils.init_utils import uniform

  cdef floating _dot(int n, floating *x, int incx,
                     floating *y, int incy) noexcept nogil:
                                           ^
  ------------------------------------------------------------

  cornac/models/efm/recom_efm.pyx:39:42: Syntax error in C variable declaration
  cythoning cornac/models/comparer/recom_comparer_obj.pyx to cornac/models/comparer/recom_comparer_obj.cpp
tqtg commented 3 months ago

@monuoha may we know what is the version of Python that you're using?

Currently, we have pre-built binaries of Cornac for Python 3.8-3.11 on MacOS on PyPI. If you're also using one of those versions, it shouldn't recompile the Cython modules again.

monuoha commented 3 months ago

I currently use Python 3.8.8.

tqtg commented 3 months ago

That's very interesting. At the moment, it's challenging to setup the same environment as yours. May I suggest the following options:

  1. Use Conda to install Cornac.
  2. Reinstall C++ compiler using Homebrew with brew install gcc | brew link gcc, then try to install Cornac again using pip.

Let us know if it resolves your issue.

monuoha commented 3 months ago

Hello, I finally managed to install cornac using conda, but I only got version 1.7.1. How do I upgrade it to 2.1.0?

tqtg commented 3 months ago

@monuoha could you double check if it's installed from the conda-forge channel?

monuoha commented 3 months ago

conda install cornac -c conda-forge

The above command is what I used to install conda.

tqtg commented 3 months ago

You can check which version and which channel the package is pull from as shown in the image below:

Screenshot 2024-04-03 at 3 43 08 PM
monuoha commented 3 months ago

How do I access that image, I exited out of the terminal window right after cornac was installed.

tqtg commented 3 months ago

you'll see it when you run the command conda install cornac -c conda-forge

monuoha commented 3 months ago

I already ran the command, and this is what it showed me:

Collecting package metadata (current_repodata.json): - WARNING conda.models.version:get_matcher(538): Using .* with relational operator is superfluous and deprecated and will be removed in a future version of conda. Your spec was 1.7.1.*, but conda is ignoring the .* and treating it as 1.7.1
done
Solving environment: done

==> WARNING: A newer version of conda exists. <==
  current version: 4.14.0
  latest version: 24.3.0

Please update conda by running

    $ conda update -n base -c conda-forge conda

# All requested packages already installed.

Retrieving notices: ...working... done
tqtg commented 3 months ago

you can uninstall cornac with conda uninstall cornac and try again with the command above

monuoha commented 3 months ago

I uninstalled it and then reinstalled it, and here is what I got

The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    conda-22.9.0               |   py38h50d1736_2         966 KB  conda-forge
    ------------------------------------------------------------
                                           Total:         966 KB

The following NEW packages will be INSTALLED:

  cornac             conda-forge/osx-64::cornac-1.7.1-py38h9529b5f_0 None
  python_abi         conda-forge/osx-64::python_abi-3.8-2_cp38 None

The following packages will be UPDATED:

  conda              pkgs/main::conda-22.9.0-py38hecd8cb5_0 --> conda-forge::conda-22.9.0-py38h50d1736_2 None
monuoha commented 3 months ago

Also, another issue that I encountered when using cornac is that my kernel on Jupyter Notebook would always die whenever I try to train the BPR model.