Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Import Error
#1
Hello everyone

I downloaded a Github repo.
this is the main directory
Quote:baselines common configs envs firl fuck logs README.md run.sh utils

 import sys, os, time
  6 
  7 for i in sys.path:
  8     print(i)
  9 
 10 import numpy as np
 11 import torch
 12 import gym
 13 from ruamel.yaml import YAML
 14 
 15 from firl.divs.f_div import f_div_loss, f_div_current_state_loss
 16 from firl.divs.ipm import ipm_loss
 17 from firl.models.reward import MLPReward
 18 from firl.models.discrim import SMMIRLDisc as Disc
 19 from firl.models.discrim import SMMIRLCritic as Critic
 20 from common.sac import ReplayBuffer, SAC
 21 
 22 import envs
 23 from envs.tasks.grid_task import expert_density
 24 #from utils import system, collect, logger, eval
 25 from fk import system
 26 #from utils.plots.train_plot import plot, plot_disc, plot_submission
 27 #from utils import plot_submission
 28 from sklearn import neighbors
In line 24 (uncomment)
I will get an error that
Output:
Traceback (most recent call last): File "firl/irl_density.py", line 24, in <module> from utils import system, collect, logger, eval ImportError: cannot import name 'system'
I copied the folder into "fk" folder in this case its working Wall

What could be the reason? I am not allowed to use the name "utils" as folder
Thank you very much :)

Best Regards
Chris
Reply
#2
Usually means there's a circular dependency between the modules. What's the repo?
Reply
#3
Thank you for your answer
If you wanna have a look
https://github.com/twni2016/f-IRL.git

It does not look like circular dependency
in system.py is no import of this kinda
Reply
#4
Hmm. Don't know. That thing has a lot of dependencies, and it won't work at all on my normal 3.9, but on 3.8.6 I was able to get everything installed and I couldn't reproduce the error. I was able to run this script.

Try a fresh venv install?

import sys,os,time
import numpy as np
import torch
import gym
from ruamel.yaml import YAML

from firl.divs.f_div import f_div_loss, f_div_current_state_loss
from firl.divs.ipm import ipm_loss
from firl.models.reward import MLPReward
from firl.models.discrim import SMMIRLDisc as Disc
from firl.models.discrim import SMMIRLCritic as Critic
from common.sac import ReplayBuffer, SAC

import envs
from envs.tasks.grid_task import expert_density

from utils import system, collect, logger, eval
print(dir(system))
Output:
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'np', 'os', 'random', 'reproduce', 'torch']
Output:
$ pip list Package Version ----------------- ------- cloudpickle 1.6.0 cycler 0.10.0 future 0.18.2 gym 0.18.0 joblib 1.0.1 kiwisolver 1.3.1 matplotlib 3.4.1 numpy 1.20.2 Pillow 7.2.0 pip 20.2.1 pyglet 1.5.0 pyparsing 2.4.7 python-dateutil 2.8.1 ruamel.yaml 0.17.4 ruamel.yaml.clib 0.2.2 scikit-learn 0.24.1 scipy 1.6.2 setuptools 49.2.1 six 1.15.0 sklearn 0.0 threadpoolctl 2.1.0 torch 1.8.1 typing-extensions 3.7.4.3
Output:
$ ls README.md baselines common configs envs firl importer.py run.sh utils
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Error on import: SyntaxError: source code string cannot contain null bytes kirkwilliams2049 7 6,632 Aug-03-2023, 06:00 PM
Last Post: Gribouillis
  import module error tantony 5 3,434 Dec-15-2022, 01:55 PM
Last Post: Lauraburmrs
  Cryptic Error with import statement Led_Zeppelin 2 2,529 Jan-11-2022, 01:13 PM
Last Post: Led_Zeppelin
  Install any library via pip get an error cannot import name 'SCHEME_KEYS' from 'pip. Anldra12 2 10,606 Jan-04-2022, 01:05 PM
Last Post: Anldra12
  import module with syntax error Skaperen 7 5,264 Jun-22-2021, 10:38 AM
Last Post: Skaperen
  Folium import error kashif_flavio 2 3,640 Dec-07-2020, 08:58 AM
Last Post: bowlofred
  Import error Beingcode 0 2,494 Nov-20-2020, 02:57 AM
Last Post: Beingcode
Smile Import error with local file colt 1 1,919 Nov-08-2020, 07:56 AM
Last Post: Gribouillis
  switch from version 3.5.3 to 3.8.6 get import error python001 9 3,955 Oct-31-2020, 03:02 PM
Last Post: python001
  import yaml error for python3 maiya 4 13,117 Jul-15-2020, 06:07 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020