bayesiains / nflows

Normalizing flows in PyTorch
MIT License
851 stars 119 forks source link

Can't import `nflows`, get `No module named 'nflows.distributions'; 'nflows' is not a package` #46

Closed romanovzky closed 3 years ago

romanovzky commented 3 years ago

Hi there,

Just installed the nflows package using pip and tried to run the example on ipython and got this:

In [1]: from nflows import transforms, distributions, flows
   ...: 
   ...: # Define an invertible transformation.
   ...: transform = transforms.CompositeTransform([
   ...:     transforms.MaskedAffineAutoregressiveTransform(features=2, hidden_features=4),
   ...:     transforms.RandomPermutation(features=2)
   ...: ])
   ...: 
   ...: # Define a base distribution.
   ...: base_distribution = distributions.StandardNormal(shape=[2])
   ...: 
   ...: 
   ...: # Combine into a flow.
   ...: flow = flows.Flow(transform=transform, distribution=base_distribution)
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-73851c844ba7> in <module>
----> 1 from nflows import transforms, distributions, flows
      2 
      3 # Define an invertible transformation.
      4 transform = transforms.CompositeTransform([
      5     transforms.MaskedAffineAutoregressiveTransform(features=2, hidden_features=4),

~/HEP_Tools/2HDMSP-1.1.2-Miguel/nflows.py in <module>
      9 from torch import nn, optim
     10 
---> 11 from nflows.distributions.normal import StandardNormal
     12 from nflows.flows.base import Flow
     13 from nflows.transforms.autoregressive import MaskedAffineAutoregressiveTransform

ModuleNotFoundError: No module named 'nflows.distributions'; 'nflows' is not a package

In [2]: 

Any other information you need from me to further debug? Cheers

Further info

$ pip list --user | grep nflows
nflows                   0.14

and package exists in $HOME/.local/lib/python3.9/site-packages/nflows.

Using Manjaro Linux.

romanovzky commented 3 years ago

I made the stupid mistake of giving my working script the name nflows :roll_eyes: sorry for that