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

A circular import in utils/misc.py #119

Closed
vis-opt-group opened this issue Dec 24, 2021 · 12 comments
Closed

A circular import in utils/misc.py #119

vis-opt-group opened this issue Dec 24, 2021 · 12 comments

Comments

@vis-opt-group
Copy link

I encountered this problem when running the following command

python ./src/main.py -t -metrics is fid prdc -cfg ./src/configs/CIFAR10/LGAN.yaml -data ./data/ -save ./result/

Traceback (most recent call last):
File "/root/gan/PyTorch-StudioGAN-master/src/main.py", line 19, in
import config
File "/root/gan/PyTorch-StudioGAN-master/src/config.py", line 16, in
import utils.misc as misc
File "/root/gan/PyTorch-StudioGAN-master/src/utils/misc.py", line 33, in
import utils.sample as sample
File "/root/gan/PyTorch-StudioGAN-master/src/utils/sample.py", line 21, in
import utils.losses as losses
File "/root/gan/PyTorch-StudioGAN-master/src/utils/losses.py", line 36, in
import utils.misc as misc
AttributeError: module 'utils' has no attribute 'misc'

@mingukkang
Copy link
Collaborator

image

In my case, the command you provide works well.

Could you please give me more information about your environment and execution specification?

Thank you.

@lizaitang
Copy link

I think it is a circular imports problem for utils, please solve it.

@mingukkang
Copy link
Collaborator

Could you please pull the repository and check it again?

@Muaz65
Copy link

Muaz65 commented Jan 13, 2022

is there any update on this? I am still getting this issue

Traceback (most recent call last): File "./src/main.py", line 19, in <module> import config File "/home/omnoai/Desktop/Muaz/PyTorch-StudioGAN/src/config.py", line 16, in <module> import utils.misc as misc ModuleNotFoundError: No module named 'utils.misc'

@mingukkang
Copy link
Collaborator

mingukkang commented Jan 13, 2022

could you give me the details of your environment including os, python, and torch version?

@Muaz65
Copy link

Muaz65 commented Jan 13, 2022

I am using ubuntu 18.06 with following versions
torch 1.10.1
torchaudio 0.4.0
torchsummary 1.5.1
torchvision 0.11.2
python 3.6.12

@mingukkang
Copy link
Collaborator

mingukkang commented Jan 13, 2022

Lastly, can you give me a command to execute the code?
Thank you so much:)
I will update PyTorch-StudioGAN ASAP.

@Muaz65
Copy link

Muaz65 commented Jan 13, 2022

Thankyou for swift response. I also tried different tags and log branch. The issue persists. I have tried all possible combination with and without terminal args.

python3 src/main.py -t -metrics is fid prdc -cfg ./src/configs/CIFAR10/LGAN.yaml -data ./data/ -save ./results/

@alex4727
Copy link
Collaborator

alex4727 commented Jan 13, 2022 via email

@Muaz65
Copy link

Muaz65 commented Jan 13, 2022

I copied the wrong command (have fixed it now). I am using the correct path and the issue persists

@Muaz65
Copy link

Muaz65 commented Jan 13, 2022

I have fixed the error by adding following code:
import sys
sys.path.append("./src/utils")

Following files are effected:

  • src/config.py
  • src/utils/ckpt.py
  • src/utils/losses.py
  • src/utils/sample.py
  • src/utils/misc.py

But this is just a temporary fix.

@mingukkang
Copy link
Collaborator

I have found that the problem is a circular import problem that occurs when using python 3.6 version.

I solved the problem, so please let me know if there still exists an import issue by pulling the main branch.

Thank you.

Minguk

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

5 participants