Fixing Error #15: Initializing libiomp5.dylib, but found libiomp5.dylib already initialized

Error #15: Initializing libiomp5.dylib, but found libiomp5.dylib already initialized is an error caused either by a faulty TensorFlow installation or incompatibility problems between TensorFlow and the package or packages.

In the blog post I attempt to explain why this error takes place and how you can solve it, I will also add other solutions that could solve the error if possible.

Exploring Error #15: Initializing libiomp5.dylib, but found libiomp5.dylib already initialized

The error is caused either by a faulty TensorFlow installation or incompatibility problems between TensorFlow and the package or packages.

Please make sure the error message looks like the error message bellow after double checking. Do not mix between errors.

                                                                       #
Error #15: Initializing libiomp5.dylib, but found libiomp5.dylib already initialized
                                                                       #

Bellow I will present multiple solutions some have worked for me and others have worked for other developers.

Solution 1 : install the nomk package using – conda install nomkl

This error occurs a lot on MacOs. If you are using one or some of these libraries in your project.

You can solve this problem by installing the nomk package using conda. The nomk package is not a Python package, it is a conda metapackage. it controls whether other packages (such as NumPy) use Intel’s MKL library for their BLAS implementation.

So, installing the nomk package might be the key to solve your issue. You can install it using conda just like in the command bellow.

                                                                       #
conda install nomkl
                                                                       #

This solution is the easiest fix to implement and the one I deemed more likely to work for most people. Please try the solution bellow if this one does not work.

Solution 2 : pip uninstall TensorFlow and then re-install again

This could sound weird to a lot of you. But sometimes the solution can be as simple as uninstalling and then re-installing TensorFlow.

Its literally just two commands, you can use pip to take care of that.

                                                                       #
  # uninstall tensorflow
pip uninstall tensorflow 
   # re-install tensorflow again
pip install tensorflow
                                                                       #

If this solution does not work, try the last solution.

Solution 3 : use conda remove mkl mkl-service and/or conda install –revision 0

This solution is kind of an extension or a complementary step to the first solution.

I proposed using the nomk package in order to get rid of the problem. If the error does not go away.

Or if you get this new error.

                                                                       #
UnsatisfiableError: The following specifications..
                                                                       #

Use the command below to uninstall all the packages you have installed.

                                                                       #
conda install --revision 0
                                                                       #

You can try installing all the packages you want to install for that project. And once you are done installing ALL of those packages.

Make sure to use the command bellow to get rid of mkl for good.

                                                                       #
conda remove mkl mkl-service
                                                                       #

This error could be confusing at first. But once you understand why it is happening, it is easy to solve by only using a more recent method that works and achieves the same function.

Summing-up

The error above can be very confusing. The fix is simple and works for most cases, thank you for reading and cheers.

If you want to learn more about Python, please check out the Python Documentation : https://docs.python.org/3/