DiffEqML / torchdyn

A PyTorch library entirely dedicated to neural differential equations, implicit models and related numerical methods
https://torchdyn.org
Apache License 2.0
1.33k stars 124 forks source link

Module not found error for 'import torchdyn' #194

Closed agoryuno closed 10 months ago

agoryuno commented 1 year ago

Describe the bug

Unable to import torchdyn installed with pip inside a Docker image.

I've tried importing in a JupyterLab instance, ipython shell and by simply executing a script with a single line: 'import torchdyn'. All methods result in:

Traceback (most recent call last):
  File "/home/jovyan/test.py", line 1, in <module>
    import torchdyn
ModuleNotFoundError: No module named 'torchdyn'

pip list shows that "torchdyn 1.0.4" is installed.

Step to Reproduce

Steps to reproduce the behavior:

  1. Build a docker image from the following Dockerfile:
FROM jupyter/datascience-notebook:ubuntu-20.04

RUN pip install numpy pandas
RUN pip install torchdyn
USER jovyan
  1. Create a 'work' dir in the current directory with mkdir work

  2. Run the image with docker run -p 8888:8888 -v $(pwd)/work:/home/jovyan/work -it jupyter-image

  3. Open JupyterLab and try importing torchdyn

  4. Close JupyterLab and restart the image with docker run -p 8888:8888 -v $(pwd)/work:/home/jovyan/work -it jupyter-image /bin/bash

  5. Start ipython and try import torchdyn

  6. Exit ipython, do: echo "import torchdyn" > test.py; python test.py

Expected behavior

For torchdyn to be properly imported

Additional context

I've had the same problem on latest Ubuntu 23.04 but assumed that this is a Python 3.11 incompatibility, so I tried with Ubuntu 20.04 and Python 3.10 in Docker to no avail.

agoryuno commented 1 year ago

I've tried installing directly from the main branch as pip install git+https://github.com/DiffEqML/torchdyn and the problem went away. So this seems to be some kind of a pip package problem.

maulberto3 commented 11 months ago

@agoryuno I had a similar issue, after installing torchdyn, jupyter just wouldn't see it. There is a problem with the installer, they must fix. I detected that the final problem is that it wouldn't install just like any other package, where you get the folder and another one called dist-.... Take a look at it yourself, go to site-packages folder or where everything gets downloaded. So, torchdyn just installs the dist one folder, why, I can't say, anyways, falling to import it because what the importing this in any python environment is to call the folder, where as mentioned somehow is not installed just like any other package. So, my workaround was, naturally, to just clone the repo, look the downloaded folder in my computer and just drop it in the site-packages folder. Complete manual workaround. It worked.

josephdviviano commented 11 months ago

This commit should have fixed the issue

https://github.com/DiffEqML/torchdyn/commit/fcab1e2854d65f88c102c8f1259b8a905f8dbda0

but I don't think they have released a new version on pypi for a while.

atong01 commented 10 months ago

Fixed on pypi in release 1.0.5 https://github.com/DiffEqML/torchdyn/releases/tag/1.0.5.1