PythonOT / POT

POT : Python Optimal Transport
https://PythonOT.github.io/
MIT License
2.43k stars 500 forks source link

ImportError: cannot import name 'proj_simplex' from 'ot.utils' #320

Closed izzatum closed 2 years ago

izzatum commented 2 years ago

Hi! Thanks for the amazing package! I really love it.

Describe the bug

I experienced an ImportError when running the plot_wass1d_torch.ipynb tutorial. The error as follows:

`--------------------------------------------------------------------------- ImportError Traceback (most recent call last) /var/folders/3q/yps71nyj565b2g31vrgbwr50fztv4w/T/ipykernel_11300/4120944215.py in 11 from ot.lp import wasserstein_1d 12 from ot.datasets import make_1D_gauss as gauss ---> 13 from ot.utils import proj_simplex 14 15 red = np.array(mpl.colors.to_rgb('red'))

ImportError: cannot import name 'proj_simplex' from 'ot.utils' (/Users/izzatum/opt/anaconda3/lib/python3.8/site-packages/ot/utils.py)`

To Reproduce

Steps to reproduce the behavior:

  1. Open and run plot_wass1d_torch.ipynb tutorial
  2. import from ot.utils import proj_simplex

Environment (please complete the following information):

Output of the following code snippet:

import platform; print(platform.platform())
import sys; print("Python", sys.version)
import numpy; print("NumPy", numpy.__version__)
import scipy; print("SciPy", scipy.__version__)
import ot; print("POT", ot.__version__)

macOS-10.16-x86_64-i386-64bit Python 3.8.12 | packaged by conda-forge | (default, Oct 12 2021, 21:50:38) [Clang 11.1.0 ] NumPy 1.20.3 SciPy 1.7.3 POT 0.7.0

Thanks!

rflamary commented 2 years ago

Hello, You are using an old version of POT. You should update it to version 0.8.0 that has this function.

izzatum commented 2 years ago

Hi! That’s strange. I’m installed it using conda as mentioned on the website. Does conda use the old version?

On Fri, 10 Dec 2021 at 12:21 PM Rémi Flamary @.***> wrote:

Hello, You are using an old version of POT. You should update it to version 0.8.0 that has this function.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://urldefense.com/v3/__https://github.com/PythonOT/POT/issues/320*issuecomment-990766711__;Iw!!Nmw4Hv0!n2kQwXz2v7rOZ08zxL7m9cTSjbGFdfzbKzWt821RqOHIg4yW-iCowF_2mi9ldD3_Pv-mTgsE_lca$, or unsubscribe https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/ALH7GBCGHKD3P5IVEDTEFQLUQHBA7ANCNFSM5JXX5PIQ__;!!Nmw4Hv0!n2kQwXz2v7rOZ08zxL7m9cTSjbGFdfzbKzWt821RqOHIg4yW-iCowF_2mi9ldD3_Pv-mTjuv78wc$ . Triage notifications on the go with GitHub Mobile for iOS https://urldefense.com/v3/__https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675__;!!Nmw4Hv0!n2kQwXz2v7rOZ08zxL7m9cTSjbGFdfzbKzWt821RqOHIg4yW-iCowF_2mi9ldD3_Pv-mTjPEl_1F$ or Android https://urldefense.com/v3/__https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign*3Dnotification-email*26utm_medium*3Demail*26utm_source*3Dgithub__;JSUlJSU!!Nmw4Hv0!n2kQwXz2v7rOZ08zxL7m9cTSjbGFdfzbKzWt821RqOHIg4yW-iCowF_2mi9ldD3_Pv-mTsDRr_pa$.

-- Muhammad Izzatullah

King Abdullah University of Science and Technology (KAUST) Division of Physical Sciences and Engineering Bldg. 1, Desk #0202-WS023 Thuwal 23955-6900, Kingdom of Saudi Arabia

Tel.: +966 (56) 569 7388 Email: @.***

@.**> Seismic Modeling & Inversion (SMI) Research Group* https://smi.kaust.edu.sa/

--

This message and its contents, including attachments are intended solely for the original recipient. If you are not the intended recipient or have received this message in error, please notify me immediately and delete this message from your computer system. Any unauthorized use or distribution is prohibited. Please consider the environment before printing this email.

izzatum commented 2 years ago

Hi @rflamary!

I tried to update the conda version of POT. Unfortunately, POT still stays the same version 0.7.0. Then, I uninstall the conda version and install the one from pip install POT. Now, I have an error while importing the package (as shown below). Could you assist me with this? Thanks!

import ot OMP: Error #15: Initializing libomp.dylib, but found libiomp5.dylib already initialized. OMP: Hint This means that multiple copies of the OpenMP runtime have been linked into the program. That is dangerous, since it can degrade performance or cause incorrect results. The best thing to do is to ensure that only a single OpenMP runtime is linked into the process, e.g. by avoiding static linking of the OpenMP runtime in any library. As an unsafe, unsupported, undocumented workaround you can set the environment variable KMP_DUPLICATE_LIB_OK=TRUE to allow the program to continue to execute, but that may cause crashes or silently produce incorrect results. For more information, please see http://openmp.llvm.org/ Abort trap: 6

rflamary commented 2 years ago

Hello this is a problem because the wheel was not build with the same version of the lib (anaonda vs macos python).

You shoudl unistall POT and install/build it from source with

pip install -U https://github.com/PythonOT/POT/archive/master.zip

rflamary commented 2 years ago

Note that POT 0.8 should now be available on conda-forge. i'm closing the Issue

izzatum commented 2 years ago

Sorry for the late reply. Thanks a lot!

On Tue, 14 Dec 2021 at 6:27 PM Rémi Flamary @.***> wrote:

Note that POT 0.8 should now be available on conda-forge. i'm closing the Issue

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://urldefense.com/v3/__https://github.com/PythonOT/POT/issues/320*issuecomment-993657808__;Iw!!Nmw4Hv0!iZLeWlnV9JWxkI_H6uPL1yNHUFLBeN-jEbO5GbjRCDJ3Fy5Wh7N4hsD3TvMBs_072B8DPHcnR8ta$, or unsubscribe https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/ALH7GBHP6XMO5GMVTZ5PN3DUQ5O6ZANCNFSM5JXX5PIQ__;!!Nmw4Hv0!iZLeWlnV9JWxkI_H6uPL1yNHUFLBeN-jEbO5GbjRCDJ3Fy5Wh7N4hsD3TvMBs_072B8DPDGLmhNQ$ . Triage notifications on the go with GitHub Mobile for iOS https://urldefense.com/v3/__https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675__;!!Nmw4Hv0!iZLeWlnV9JWxkI_H6uPL1yNHUFLBeN-jEbO5GbjRCDJ3Fy5Wh7N4hsD3TvMBs_072B8DPPevBQWF$ or Android https://urldefense.com/v3/__https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign*3Dnotification-email*26utm_medium*3Demail*26utm_source*3Dgithub__;JSUlJSU!!Nmw4Hv0!iZLeWlnV9JWxkI_H6uPL1yNHUFLBeN-jEbO5GbjRCDJ3Fy5Wh7N4hsD3TvMBs_072B8DPJjOwO5e$.

-- Muhammad Izzatullah

King Abdullah University of Science and Technology (KAUST) Division of Physical Sciences and Engineering Bldg. 1, Desk #0202-WS023 Thuwal 23955-6900, Kingdom of Saudi Arabia

Tel.: +966 (56) 569 7388 Email: @.***

@.**> Seismic Modeling & Inversion (SMI) Research Group* https://smi.kaust.edu.sa/

--

This message and its contents, including attachments are intended solely for the original recipient. If you are not the intended recipient or have received this message in error, please notify me immediately and delete this message from your computer system. Any unauthorized use or distribution is prohibited. Please consider the environment before printing this email.