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

pip installation using github repository incomplete #56

Closed
immanuelweber opened this issue Aug 7, 2019 · 19 comments
Closed

pip installation using github repository incomplete #56

immanuelweber opened this issue Aug 7, 2019 · 19 comments

Comments

@immanuelweber
Copy link

I tried to install pytorch-lightning using pip and the github repository.
Importing the module results in the following errors:

`
ModuleNotFoundError Traceback (most recent call last)
in
8 from torchvision import ops
9
---> 10 import pytorch_lightning as ptl
11 from pytorch_lightning import Trainer
12 from test_tube import Experiment

/opt/miniconda3/envs/dev_pytorch_lightning36/lib/python3.6/site-packages/pytorch_lightning/init.py in
----> 1 from .models.trainer import Trainer
2 from .root_module.root_module import LightningModule
3 from .root_module.decorators import data_loader

ModuleNotFoundError: No module named 'pytorch_lightning.models'`

Following the error I found out, that there is no models folder under the path site-packages\pytorch_lightning

@williamFalcon
Copy link
Contributor

williamFalcon commented Aug 7, 2019

Pip install by itself should be fine.

If you're trying to clone and run master, something might have broken with relative imports
@Borda

Make sure you're using python 3.6+ as well

@williamFalcon
Copy link
Contributor

@Borda looks like pep8 recommends absolute imports as well. let's just go back to those, i remember now why i got rid of relative imports a long time ago. Causes all sorts of headaches and it's not clear where things are coming from.

@Borda
Copy link
Member

Borda commented Aug 7, 2019

there was an error in the Trainer since the subpackage was missing __init__
it was fixed in #44 eacd93e
it is also reason for #44 becase running only py.test did not discover it :)

@williamFalcon
Copy link
Contributor

ok awesome. should be on master now

@Borda
Copy link
Member

Borda commented Aug 7, 2019

@egonuel pls could you check it now...

@immanuelweber
Copy link
Author

@Borda I just checked it and now I'm getting this error (numpy is installed):

pip install git+https://github.com/williamFalcon/pytorch-lightning.git@master --upgrade
Collecting git+https://github.com/williamFalcon/pytorch-lightning.git@master
Cloning https://github.com/williamFalcon/pytorch-lightning.git (to revision master) to /tmp/pip-req-build-42ipxsly
Running command git clone -q https://github.com/williamFalcon/pytorch-lightning.git /tmp/pip-req-build-42ipxsly
Installing build dependencies ... done
Getting requirements to build wheel ... error
ERROR: Command errored out with exit status 1:
command: /opt/miniconda3/envs/dev_pytorch_lightning36/bin/python /opt/miniconda3/envs/dev_pytorch_lightning36/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmpb9traczs
cwd: /tmp/pip-req-build-42ipxsly
Complete output (22 lines):
Traceback (most recent call last):
File "/opt/miniconda3/envs/dev_pytorch_lightning36/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 207, in
main()
File "/opt/miniconda3/envs/dev_pytorch_lightning36/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 197, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/opt/miniconda3/envs/dev_pytorch_lightning36/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 54, in get_requires_for_build_wheel
return hook(config_settings)
File "/tmp/pip-build-env-u6myx0it/overlay/lib/python3.6/site-packages/setuptools/build_meta.py", line 145, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=['wheel'])
File "/tmp/pip-build-env-u6myx0it/overlay/lib/python3.6/site-packages/setuptools/build_meta.py", line 126, in _get_build_requires
self.run_setup()
File "/tmp/pip-build-env-u6myx0it/overlay/lib/python3.6/site-packages/setuptools/build_meta.py", line 234, in run_setup
self).run_setup(setup_script=setup_script)
File "/tmp/pip-build-env-u6myx0it/overlay/lib/python3.6/site-packages/setuptools/build_meta.py", line 141, in run_setup
exec(compile(code, file, 'exec'), locals())
File "setup.py", line 5, in
import pytorch_lightning
File "/tmp/pip-req-build-42ipxsly/pytorch_lightning/init.py", line 1, in
from .models.trainer import Trainer
File "/tmp/pip-req-build-42ipxsly/pytorch_lightning/models/trainer.py", line 9, in
import numpy as np
ModuleNotFoundError: No module named 'numpy'


ERROR: Command errored out with exit status 1: /opt/miniconda3/envs/dev_pytorch_lightning36/bin/python /opt/miniconda3/envs/dev_pytorch_lightning36/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmpb9traczs Check the logs for full command output.

@Borda Borda mentioned this issue Aug 7, 2019
@Borda
Copy link
Member

Borda commented Aug 7, 2019

it seems that numpy is missing in the setup, see following fix req. in setup #60

@williamFalcon
Copy link
Contributor

Fixed with the patch from #60 on #67

@immanuelweber
Copy link
Author

I just tried to get the latest master using pip, and I still get the same error as posted above...

@immanuelweber
Copy link
Author

I googled arround a bit and this has something to do with the pip version. I had installed pip 19.2.1. After downgrading to 18.0 the installations works. For reference see here earthlab/earthpy#206
Does this work for you with a newer than 18.0 version?

@Borda
Copy link
Member

Borda commented Aug 8, 2019

@williamFalcon there are two possible solutions, fix __init__.py or setup.py

  • fixing __init__.py by wrapping import to try
try:
    from .models.trainer import Trainer
    from .root_module.root_module import LightningModule
    from .root_module.decorators import data_loader
except ImportError as e:
    print(e)
  • fixing setup.py remove loading pytorch_lightning at the beginning...

see the fix in #71, you may try it as
pip install git+https://github.com/Borda/pytorch-lightning.git@fix-setup

@Borda
Copy link
Member

Borda commented Aug 8, 2019

unfortunately, the #68 was merged in really fast fashion without complete testing...
we may consider modifying CI such way that it will test installation to blank environment
@egonuel pls reopen this ticket till it is properly fixed... :)

@immanuelweber
Copy link
Author

@Borda thanks, this runs through and installs without errors.
I don't think I can reopen this issue as it was closed by @williamFalcon

@williamFalcon
Copy link
Contributor

@egonuel sorry you’re still having install issues!

@Borda thanks for taking a look. I’m not sure whether something was introduced that broke it, haven’t had any pip install issues.

a few things:

  1. try catch seems hacky to me. let’s do the setup fix?
  2. not sure it matters but we don’t explicitly support venv, people should just be using conda here.
  3. is the only fix for setup making a relative import? i want to keep imports absolute. Haven’t had clone+install issues in this repo ever until just this week with these new changes people introduced. does it have to do with that? or maybe that we all use conda?

installing to blank environment would be a good move for CI but might be slow no?

@williamFalcon williamFalcon reopened this Aug 8, 2019
@williamFalcon
Copy link
Contributor

unfortunately, the #68 was merged in really fast fashion without complete testing...
we may consider modifying CI such way that it will test installation to blank environment
@egonuel pls reopen this ticket till it is properly fixed... :)

i run branches on my gpu machine before merging if tests pass there then i merge since those are more thorough. in some cases it may look like CI didn’t finish bc the local gpu run finishes first, which is when i merge

@Borda
Copy link
Member

Borda commented Aug 8, 2019

#56 (comment) sure but before you test the setup, you install or you already gad installed the requirements so all needed libraries were there... which is another story from installing to blank env

@Borda
Copy link
Member

Borda commented Aug 8, 2019

  1. try catch seems hacky to me. let’s do the setup fix?

up to you, if you chose fix setup you need to keep in mind that the version is at two files (setup.py and __init__.py)

  1. not sure it matters but we don’t explicitly support venv, people should just be using conda here.

for conda it should be fine since at already comes with preinstalled most libraries

  1. is the only fix for setup making a relative import? i want to keep imports absolute. Haven’t had clone+install issues in this repo ever until just this week with these new changes people introduced. does it have to do with that? or maybe that we all use conda?

relative/absolute import does not change anything in this context

installing to blank environment would be a good move for CI but might be slow no?

not necessary, it just changes order, you try to install which install also all requirement and later when you ask for requirements installation it pass since everything is already there...

williamFalcon pushed a commit that referenced this issue Aug 8, 2019
* fix loading package while setup #56

* Update setup.py

* Update __init__.py

* Update setup.py

* use complete req.

* Update setup.py

* Update setup.py
@williamFalcon
Copy link
Contributor

@egonuel try again?

@immanuelweber
Copy link
Author

@williamFalcon it works now, nice! 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

3 participants