Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to import trainer #41

Closed
sameerIISc opened this issue Aug 5, 2019 · 6 comments
Closed

Unable to import trainer #41

sameerIISc opened this issue Aug 5, 2019 · 6 comments

Comments

@sameerIISc
Copy link

Hey, I am able to import pytorch_lightning but not the trainer. I am new to python and have no idea how to deal with it. It throws following error:

File "", line 1, in
ImportError: cannot import name Trainer

Thanks

@williamFalcon
Copy link
Contributor

williamFalcon commented Aug 5, 2019

post code here.

Generally in python it would be:

from python_lightning import Trainer

Look at the demo here for instructions:
https://github.com/williamFalcon/pytorch-lightning#how-do-i-do-use-it

@sameerIISc
Copy link
Author

From command line itself it is not able to import. Importing pytorch_lightning is working though.

import pytorch_lightning
from pytorch_lightning import Trainer
Traceback (most recent call last):
File "", line 1, in
ImportError: cannot import name Trainer

@williamFalcon
Copy link
Contributor

williamFalcon commented Aug 5, 2019

  Found existing installation: pytorch-lightning 0.3.6.9
    Uninstalling pytorch-lightning-0.3.6.9:
      Successfully uninstalled pytorch-lightning-0.3.6.9
  Running setup.py develop for pytorch-lightning
Successfully installed pytorch-lightning test-tube-0.6.7.6
(lightning) user:~/Developer/pytorch-lightning$ python
Python 3.7.3 (default, Mar 27 2019, 22:11:17)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pytorch_lightning
>>> from pytorch_lightning import Trainer
>>>

Seems strange. I just tried, it works. Tests also work...

Maybe it's your install?

What does your conda env look like? Are you also using the latest lightning version?

@sameerIISc
Copy link
Author

Even after re-installation, same problem persists.

(sameer27) ece@ece-System-Product-Name:~$ pip install pytorch_lightning
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Collecting pytorch_lightning
Collecting test-tube (from pytorch_lightning)
Requirement already satisfied: torch in ./anaconda2/envs/sameer27/lib/python2.7/site-packages (from pytorch_lightning) (1.1.0)
Requirement already satisfied: tqdm in ./anaconda2/envs/sameer27/lib/python2.7/site-packages (from pytorch_lightning) (4.32.2)
Requirement already satisfied: numpy>=1.13.3 in ./.local/lib/python2.7/site-packages (from test-tube->pytorch_lightning) (1.14.0)
Requirement already satisfied: pandas>=0.20.3 in ./anaconda2/envs/sameer27/lib/python2.7/site-packages (from test-tube->pytorch_lightning) (0.24.2)
Requirement already satisfied: future in ./anaconda2/envs/sameer27/lib/python2.7/site-packages (from test-tube->pytorch_lightning) (0.17.1)
Requirement already satisfied: tb-nightly==1.15.0a20190708 in ./anaconda2/envs/sameer27/lib/python2.7/site-packages (from test-tube->pytorch_lightning) (1.15.0a20190708)
Requirement already satisfied: imageio>=2.3.0 in ./anaconda2/envs/sameer27/lib/python2.7/site-packages (from test-tube->pytorch_lightning) (2.5.0)
Requirement already satisfied: pytz>=2011k in ./.local/lib/python2.7/site-packages (from pandas>=0.20.3->test-tube->pytorch_lightning) (2017.3)
Requirement already satisfied: python-dateutil>=2.5.0 in ./.local/lib/python2.7/site-packages (from pandas>=0.20.3->test-tube->pytorch_lightning) (2.6.1)
Requirement already satisfied: grpcio>=1.6.3 in ./.local/lib/python2.7/site-packages (from tb-nightly==1.15.0a20190708->test-tube->pytorch_lightning) (1.21.1)
Requirement already satisfied: absl-py>=0.4 in ./.local/lib/python2.7/site-packages (from tb-nightly==1.15.0a20190708->test-tube->pytorch_lightning) (0.7.1)
Requirement already satisfied: protobuf>=3.6.0 in ./.local/lib/python2.7/site-packages (from tb-nightly==1.15.0a20190708->test-tube->pytorch_lightning) (3.8.0)
Requirement already satisfied: futures>=3.1.1; python_version < "3" in ./.local/lib/python2.7/site-packages (from tb-nightly==1.15.0a20190708->test-tube->pytorch_lightning) (3.2.0)
Requirement already satisfied: wheel; python_version < "3" in ./.local/lib/python2.7/site-packages (from tb-nightly==1.15.0a20190708->test-tube->pytorch_lightning) (0.33.4)
Requirement already satisfied: werkzeug>=0.11.15 in ./.local/lib/python2.7/site-packages (from tb-nightly==1.15.0a20190708->test-tube->pytorch_lightning) (0.15.4)
Requirement already satisfied: markdown>=2.6.8 in ./.local/lib/python2.7/site-packages (from tb-nightly==1.15.0a20190708->test-tube->pytorch_lightning) (3.1.1)
Requirement already satisfied: six>=1.10.0 in ./.local/lib/python2.7/site-packages (from tb-nightly==1.15.0a20190708->test-tube->pytorch_lightning) (1.12.0)
Requirement already satisfied: setuptools>=41.0.0 in ./.local/lib/python2.7/site-packages (from tb-nightly==1.15.0a20190708->test-tube->pytorch_lightning) (41.0.1)
Requirement already satisfied: pillow in ./.local/lib/python2.7/site-packages (from imageio>=2.3.0->test-tube->pytorch_lightning) (5.0.0)
Requirement already satisfied: enum34 in ./.local/lib/python2.7/site-packages (from imageio>=2.3.0->test-tube->pytorch_lightning) (1.1.6)
Installing collected packages: test-tube, pytorch-lightning
Successfully installed pytorch-lightning-0.0.2 test-tube-0.6.7.6
(sameer27) ece@ece-System-Product-Name:~$ python
Python 2.7.16 |Anaconda, Inc.| (default, Mar 14 2019, 21:00:58) 
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pytorch_lightning
>>> from pytorch_lightning import Trainer
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name Trainer

@williamFalcon
Copy link
Contributor

oh yeah, use python 3+. Recommended 3.7

@sameerIISc
Copy link
Author

Ok, I will try it. Thanks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants