One hot encoding large dataset Initially, I have a dataset where for each row there is user_id and product_ids he bought.

In that dataset there are 478191 products bought by different users. 

In order to discover frequent items that are bought together, I will use association rules, apriori algorithm.
As apriori algorithm expects to have the features one-hot encoded.   I need the product_ids one-hot encoded.

Scikit-learn one-Hot encoding (sparse matrix=True) resulted in memory error. What other methods can I try? (using Python)
Apparently, you need an implementation of the a priori algorithm (or whatever algorithm you want to use) that supports sparse feature vectors.  If one doesn't already exist, you might need to implement it yourself.

Alternatively, you can use the feature hashing trick.  However, beware that it can cause loss of accuracy and loss of interpretability; nothing comes for free.