Pytorch-lightning: Cannot import pytorch-lightning-v0.5.3

Created on 7 Nov 2019  路  16Comments  路  Source: PyTorchLightning/pytorch-lightning

Describe the bug

After updating to v0.5.3, import pytorch_lightning fails due to the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/pytorch_lightning/__init__.py", line 28, in <module>
    from .trainer.trainer import Trainer
  File "/usr/local/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 16, in <module>
    from pytorch_lightning.trainer.callback_config_mixin import TrainerCallbackConfigMixin
  File "/usr/local/lib/python3.7/site-packages/pytorch_lightning/trainer/callback_config_mixin.py", line 4, in <module>
    from pytorch_lightning.logging import TestTubeLogger
ImportError: cannot import name 'TestTubeLogger' from 'pytorch_lightning.logging' (/usr/local/lib/python3.7/site-packages/pytorch_lightning/logging/__init__.py)

To Reproduce

Steps to reproduce the behavior:

$ docker run --rm -it python:3.7 /bin/bash 

//
// Install `pytorch_lightning` (succeeded)
//
root@93bfd08b5db7:/# pip install pytorch_lightning
Collecting pytorch_lightning
  Downloading https://files.pythonhosted.org/packages/2d/2e/ef5bedf1bb7f2f786d42f5af71ad5d7383416efec86098372d8016f5305d/pytorch-lightning-0.5.3.tar.gz (55kB)
...
Building wheels for collected packages: pytorch-lightning
  Building wheel for pytorch-lightning (setup.py) ... done
  Created wheel for pytorch-lightning: filename=pytorch_lightning-0.5.3-cp37-none-any.whl size=67557 sha256=80287a76e8fa15b4a64568fcd0c033688479f1bf7cb69dde8ba1d77da25453a6
  Stored in directory: /root/.cache/pip/wheels/0f/4e/df/486c6c64d8d2f4706c70255493e434bacbf3497c7f5d0ab040
Successfully built pytorch-lightning
Installing collected packages: numpy, scipy, scikit-learn, tqdm, chardet, certifi, urllib3, idna, requests, docutils, webencodings, six, bleach, Pygments, readme-renderer, pkginfo, requests-toolbelt, twine, torch, pillow, torchvision, pytz, python-dateutil, pandas, pytorch-lightning
Successfully installed Pygments-2.4.2 bleach-3.1.0 certifi-2019.9.11 chardet-3.0.4 docutils-0.15.2 idna-2.8 numpy-1.16.4 pandas-0.25.3 pillow-6.2.1 pkginfo-1.5.0.1 python-dateutil-2.8.1 pytorch-lightning-0.5.3 pytz-2019.3 readme-renderer-24.0 requests-2.22.0 requests-toolbelt-0.9.1 scikit-learn-0.20.2 scipy-1.3.1 six-1.13.0 torch-1.3.0 torchvision-0.4.1 tqdm-4.35.0 twine-1.13.0 urllib3-1.25.6 webencodings-0.5.1

//
// Import `pytorch_lightning` (failed)
//
root@93bfd08b5db7:/# python
Python 3.7.5 (default, Oct 19 2019, 00:03:48)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pytorch_lightning
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/pytorch_lightning/__init__.py", line 28, in <module>
    from .trainer.trainer import Trainer
  File "/usr/local/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py", line 16, in <module>
    from pytorch_lightning.trainer.callback_config_mixin import TrainerCallbackConfigMixin
  File "/usr/local/lib/python3.7/site-packages/pytorch_lightning/trainer/callback_config_mixin.py", line 4, in <module>
    from pytorch_lightning.logging import TestTubeLogger
ImportError: cannot import name 'TestTubeLogger' from 'pytorch_lightning.logging' (/usr/local/lib/python3.7/site-packages/pytorch_lightning/logging/__init__.py)
bug / fix

Most helpful comment

I had the same error, too
cannot import name 'TestTubeLogger'
I tried
pip install test-tube
and it says

Requirement already satisfied: test-tube in /home/rpc/anaconda3/envs/hkt/lib/python3.6/site-packages (0.7.3)
Requirement already satisfied: future in /home/rpc/anaconda3/envs/hkt/lib/python3.6/site-packages (from test-tube) (0.18.2)
Requirement already satisfied: imageio>=2.3.0 in /home/rpc/anaconda3/envs/hkt/lib/python3.6/site-packages (from test-tube) (2.5.0)
Requirement already satisfied: pandas>=0.20.3 in /home/rpc/anaconda3/envs/hkt/lib/python3.6/site-packages (from test-tube) (0.24.2)
Requirement already satisfied: torch>=1.1.0 in /home/rpc/anaconda3/envs/hkt/lib/python3.6/site-packages (from test-tube) (1.3.1)
Requirement already satisfied: numpy>=1.13.3 in /home/rpc/.local/lib/python3.6/site-packages (from test-tube) (1.16.4)
Requirement already satisfied: tb-nightly==1.15.0a20190708 in /home/rpc/anaconda3/envs/hkt/lib/python3.6/site-packages (from test-tube) (1.15.0a20190708)
Requirement already satisfied: pytz>=2011k in /home/rpc/anaconda3/envs/hkt/lib/python3.6/site-packages (from pandas>=0.20.3->test-tube) (2018.9)
Requirement already satisfied: python-dateutil>=2.5.0 in /home/rpc/anaconda3/envs/hkt/lib/python3.6/site-packages (from pandas>=0.20.3->test-tube) (2.8.0)
Requirement already satisfied: six>=1.10.0 in /home/rpc/.local/lib/python3.6/site-packages (from tb-nightly==1.15.0a20190708->test-tube) (1.12.0)
Requirement already satisfied: protobuf>=3.6.0 in /home/rpc/anaconda3/envs/hkt/lib/python3.6/site-packages (from tb-nightly==1.15.0a20190708->test-tube) (3.8.0)
Requirement already satisfied: markdown>=2.6.8 in /home/rpc/anaconda3/envs/hkt/lib/python3.6/site-packages (from tb-nightly==1.15.0a20190708->test-tube) (3.1.1)
Requirement already satisfied: setuptools>=41.0.0 in /home/rpc/anaconda3/envs/hkt/lib/python3.6/site-packages (from tb-nightly==1.15.0a20190708->test-tube) (41.0.1)
Requirement already satisfied: absl-py>=0.4 in /home/rpc/anaconda3/envs/hkt/lib/python3.6/site-packages (from tb-nightly==1.15.0a20190708->test-tube) (0.7.1)
Requirement already satisfied: werkzeug>=0.11.15 in /home/rpc/anaconda3/envs/hkt/lib/python3.6/site-packages (from tb-nightly==1.15.0a20190708->test-tube) (0.14.1)
Requirement already satisfied: grpcio>=1.6.3 in /home/rpc/anaconda3/envs/hkt/lib/python3.6/site-packages (from tb-nightly==1.15.0a20190708->test-tube) (1.16.1)
Requirement already satisfied: wheel>=0.26; python_version >= "3" in /home/rpc/anaconda3/envs/hkt/lib/python3.6/site-packages (from tb-nightly==1.15.0a20190708->test-tube) (0.33.1)

but after that, I had exactly the same error again,
How can I do?

All 16 comments

@sile you need to install test-tube from pypi

@Borda My problem was solved by installing test-tube. Thank you!

BTW, I think that it's better to add test-tube to requirements.txt if the package is mandatory to import pytorch_lightning.

I am not sure about it, we had similar discussion some time ago and we decided that we don't want to forse users of mlflow (or other alternatives) to use test-tube so lightning can be installed without any of these dependencies and we leave the decision about preferable logger to the user... That's also why there is integration of the three main logging tools :)

@sile but I agree that the package should not crash just after importing pytorch_lightning...
I will have look at it, pls reopen this issue 8-)

Reopened.

we leave the decision about preferable logger to the user

Sounds good. Thank you for your explanation.

we need to submit a fix for test-tube

Fixed on master. we can drop the reqs for next release

Great! Thank you!

@williamFalcon so now e41bf0a047085037cb7e37d4c3cb95aab0e218f6 you force users to use test-tube?
I thought that we let them chose https://github.com/williamFalcon/pytorch-lightning/issues/469#issuecomment-550593621

users should have a choice. i鈥檇 like to not force it. but crash on install is not good UX. UX takes priority.

once install works without crashing because of test-tube we can remove the requirement.

I know that is why I prepared a fix, but I agree that it can go in the next release...

@Borda on second thought, i don't think we can get rid of test-tube logger as a dependency because we need a default logger when people use the trainer.

A happy medium would be to implement a tensorboard logger using PyTorch SummaryWriter which would be the default logger.

I had the same error, too
cannot import name 'TestTubeLogger'
I tried
pip install test-tube
and it says

Requirement already satisfied: test-tube in /home/rpc/anaconda3/envs/hkt/lib/python3.6/site-packages (0.7.3)
Requirement already satisfied: future in /home/rpc/anaconda3/envs/hkt/lib/python3.6/site-packages (from test-tube) (0.18.2)
Requirement already satisfied: imageio>=2.3.0 in /home/rpc/anaconda3/envs/hkt/lib/python3.6/site-packages (from test-tube) (2.5.0)
Requirement already satisfied: pandas>=0.20.3 in /home/rpc/anaconda3/envs/hkt/lib/python3.6/site-packages (from test-tube) (0.24.2)
Requirement already satisfied: torch>=1.1.0 in /home/rpc/anaconda3/envs/hkt/lib/python3.6/site-packages (from test-tube) (1.3.1)
Requirement already satisfied: numpy>=1.13.3 in /home/rpc/.local/lib/python3.6/site-packages (from test-tube) (1.16.4)
Requirement already satisfied: tb-nightly==1.15.0a20190708 in /home/rpc/anaconda3/envs/hkt/lib/python3.6/site-packages (from test-tube) (1.15.0a20190708)
Requirement already satisfied: pytz>=2011k in /home/rpc/anaconda3/envs/hkt/lib/python3.6/site-packages (from pandas>=0.20.3->test-tube) (2018.9)
Requirement already satisfied: python-dateutil>=2.5.0 in /home/rpc/anaconda3/envs/hkt/lib/python3.6/site-packages (from pandas>=0.20.3->test-tube) (2.8.0)
Requirement already satisfied: six>=1.10.0 in /home/rpc/.local/lib/python3.6/site-packages (from tb-nightly==1.15.0a20190708->test-tube) (1.12.0)
Requirement already satisfied: protobuf>=3.6.0 in /home/rpc/anaconda3/envs/hkt/lib/python3.6/site-packages (from tb-nightly==1.15.0a20190708->test-tube) (3.8.0)
Requirement already satisfied: markdown>=2.6.8 in /home/rpc/anaconda3/envs/hkt/lib/python3.6/site-packages (from tb-nightly==1.15.0a20190708->test-tube) (3.1.1)
Requirement already satisfied: setuptools>=41.0.0 in /home/rpc/anaconda3/envs/hkt/lib/python3.6/site-packages (from tb-nightly==1.15.0a20190708->test-tube) (41.0.1)
Requirement already satisfied: absl-py>=0.4 in /home/rpc/anaconda3/envs/hkt/lib/python3.6/site-packages (from tb-nightly==1.15.0a20190708->test-tube) (0.7.1)
Requirement already satisfied: werkzeug>=0.11.15 in /home/rpc/anaconda3/envs/hkt/lib/python3.6/site-packages (from tb-nightly==1.15.0a20190708->test-tube) (0.14.1)
Requirement already satisfied: grpcio>=1.6.3 in /home/rpc/anaconda3/envs/hkt/lib/python3.6/site-packages (from tb-nightly==1.15.0a20190708->test-tube) (1.16.1)
Requirement already satisfied: wheel>=0.26; python_version >= "3" in /home/rpc/anaconda3/envs/hkt/lib/python3.6/site-packages (from tb-nightly==1.15.0a20190708->test-tube) (0.33.1)

but after that, I had exactly the same error again,
How can I do?

I had the same error, too
cannot import name 'TestTubeLogger'

I have installed test-tube. how to solve it?
Thanks

pls try pip install pytorch-lightning["extra"]

Was this page helpful?
0 / 5 - 0 ratings

Related issues

srush picture srush  路  3Comments

maxime-louis picture maxime-louis  路  3Comments

iakremnev picture iakremnev  路  3Comments

polars05 picture polars05  路  3Comments

remisphere picture remisphere  路  3Comments