googlecolab / colabtools

Python libraries for Google Colaboratory
Apache License 2.0
2.18k stars 713 forks source link

Cannot Import torchnet in Colab. ModuleNotFoundError: No module named 'visdom.utils' #3171

Closed ron8520 closed 1 year ago

ron8520 commented 1 year ago

Not sure what is going on.

I have successfully imported this module and trained my model for a while, and it does not work anymore today.

the command to install this library

!pip install torchnet

it has been successfully installed, however, when I import this library

import torchnet as tnt

It raises the error with

Traceback (most recent call last): File "/content/drive/MyDrive/thesis/train_transformer_semantic.py", line 17, in import torchnet as tnt File "/usr/local/lib/python3.7/dist-packages/torchnet/init.py", line 1, in from . import dataset, meter, engine, transform, logger File "/usr/local/lib/python3.7/dist-packages/torchnet/logger/init.py", line 1, in from .visdomlogger import VisdomLogger, VisdomPlotLogger, VisdomSaver, VisdomTextLogger File "/usr/local/lib/python3.7/dist-packages/torchnet/logger/visdomlogger.py", line 3, in import visdom File "/usr/local/lib/python3.7/dist-packages/visdom/init.py", line 9, in from visdom.utils.shared_utils import get_new_window_id ModuleNotFoundError: No module named 'visdom.utils'

I have tried restarting the Colab kernel, reinstalling this by upgrading pip and using pip3 to install with no luck.

Also, I ask a friend to repeat my steps in his Colab environment. He meets the same error. I hope this can be resolved as soon as possible.

mco-gh commented 1 year ago

I'm able to reproduce this. It appears that visdom is not working properly, because the following simplifed sequence fails in colab with identical results:

pip3 install visdom
import visdom

Also, I've verified the same behavior in the python repl running on my laptop:

(after successfully pip installing visdom...)
$ py
>>> import visdom
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/marccohen/.pyenv/versions/3.8.3/lib/python3.8/site-packages/visdom/__init__.py", line 9, in <module>
    from visdom.utils.shared_utils import get_new_window_id
ModuleNotFoundError: No module named 'visdom.utils'

So I think the default visdom version in pypi appears broken.

mco-gh commented 1 year ago

Further confirmation: if I explicitly pip install visdom==0.1.7 (vs. the latest version 0.2.2, which is what you get when you install visdom without an explicit version), then importing visdom and torchnet both work for me (in colab and Python repl). I suggest taking this up with the visdom folks.

ron8520 commented 1 year ago

Thanks for that. Yeah, I have taken a depth look at those libraries. The Visdom updated to 0.2.2 in 10 hours ago. It impacts other libraries. I used pip install visdom==0.2.1 to downgrade it and solve that issue.

duduzai2019 commented 1 year ago

谢谢你。是的,我已经深入研究了这些库。10小时前,用户升级到 0.2.2.它会影响其他库。我曾经降级它并解决这个问题。pip install visdom==0.2.1

Thanks for that. Yeah, I have taken a depth look at those libraries. The Visdom updated to 0.2.2 in 10 hours ago. It impacts other libraries. I used pip install visdom==0.2.1 to downgrade it and solve that issue.

Thanks!