open-mmlab / mmcv

OpenMMLab Computer Vision Foundation
https://mmcv.readthedocs.io/en/latest/
Apache License 2.0
5.9k stars 1.65k forks source link

from mmcv import Config ImportError: cannot import name 'Config' #1329

Closed aliman80 closed 3 years ago

aliman80 commented 3 years ago

I am trying to run code from git hub which uses mmdetection library. My code is giving me this error. Can any one guide please.

regards

zhouzaida commented 3 years ago

Provide more information like the output of pip list or the link of code?

aliman80 commented 3 years ago

zero_shot_detection:Code for ACCV 2020 Synthesizing the Unseen for Zero-shot Object Detection This is the paper https://github.com/aliman80/zero_shot_detection.git which i m trying to implement. I am novice although i have searched alot for the solution but its giving me an error

"from mmcv import Config ImportError: cannot import name 'Config' Traceback (most recent call last):"

aliman80 commented 3 years ago

Output of piplist

addict 2.4.0 certifi 2020.6.20 cffi 1.14.3 cycler 0.10.0 Cython 0.29.24 joblib 0.17.0 kiwisolver 1.3.0 matplotlib 3.3.2 mkl-fft 1.2.0 mkl-random 1.1.1 mkl-service 2.3.0 mmcv-full 1.3.12 mmdet 2.16.0 numpy 1.19.2 olefile 0.46 opencv-python 4.5.3.56 packaging 21.0 pandas 1.1.3 Pillow 8.0.1 pip 20.2.4 pycocotools 2.0.2 pycparser 2.20 pyparsing 2.4.7 python-dateutil 2.8.1 pytz 2020.1 PyYAML 5.4.1 scikit-learn 0.23.2 scipy 1.5.2 seaborn 0.11.0 setuptools 50.3.0.post20201006 six 1.15.0 terminaltables 3.1.0 threadpoolctl 2.1.0 torch 1.1.0 torchvision 0.3.0 tornado 6.0.4 wheel 0.35.1

zhouzaida commented 3 years ago

You can try to import Config from mmcv in your terminal to locate the bug

>>> from mmcv import Config
zhouzaida commented 3 years ago

hi @aliman80 , is there any progress?

aliman80 commented 3 years ago

Still trying but now i have uninstalled everything and created new environment. The auther says install mmdetection from docker but i cant use sudo command in my unviersity . Is there any solution to this issue ?

Thanks for your time again

zhouzaida commented 3 years ago

You can try to import Config from mmcv in your terminal to locate the bug

>>> from mmcv import Config

You should check whether mmcv or mmcv-full was installed successfully.

aliman80 commented 3 years ago

from mmcv import Config yes i checked it its ok . I reinstalled everything and now i am getting this error

from mmdet.apis import (get_root_logger, init_dist, set_random_seed, ImportError: cannot import name 'init_dist' from 'mmdet.apis' (/home/u20020079/.conda/envs/zsd4/lib/python3.9/site-packages/mmdet/apis/init.py)

zhouzaida commented 3 years ago

hi @aliman80 , sorry for the late reply. init_dist is not included among https://github.com/open-mmlab/mmdetection/blob/v2.16.0/mmdet/apis/__init__.py so you can not directly import it

huyi666r commented 1 year ago

I have met the same problem, and i reinstalled everything,but it didnt work

cjxxu commented 1 year ago

I have met the same problem,too

anecky commented 1 year ago

I have met the same problem,too

leizhenyu-lzy commented 1 year ago

same problem on mmcv2.0.0

mmcls                  0.25.0
mmcv                   2.0.0
mmengine               0.7.2
mmsegmentation         1.0.0

install by mim

haowei2020 commented 1 year ago

You can try to import Config from mmcv in your terminal to locate the bug

>>> from mmcv import Config

You should check whether mmcv or mmcv-full was installed successfully.

It seems that Config class is not defined in MMCV 2.0.0. In MMCV 1.6.1, the Config class is defined in mmcv/utils/config.py, the same path in MMCV 2.0.0, there is no config.py.

haowei2020 commented 1 year ago

same problem on mmcv2.0.0

mmcls                  0.25.0
mmcv                   2.0.0
mmengine               0.7.2
mmsegmentation         1.0.0

install by mim

MMCV2.0.0没有定义Config, 是在MMengine中定义的

shanshui281 commented 1 year ago

same problem on mmcv2.0.0

mmcls                  0.25.0
mmcv                   2.0.0
mmengine               0.7.2
mmsegmentation         1.0.0

install by mim

MMCV2.0.0没有定义Config, 是在MMengine中定义的

请问怎么解决?多谢!

Rahmyyy commented 1 year ago

I was able to get around this by changing in my python file from "from mmcv import Config" to "from mmengine import Config" however I am getting other errors becuase of the changes. https://github.com/open-mmlab/mmcv/blob/59c1418e454a5871e1c954798c35d5fd6e970e3b/docs/en/compatibility.md?plain=1#L10

haowei2020 commented 1 year ago

换个低版本的mmcv试试,比如1.6的

郝伟

北京信息科技大学 机电工程学院

Tel:131-6330-3379

@.***

---- Replied Message ---- | From | @.> | | Date | 05/12/2023 09:29 | | To | @.> | | Cc | @.>@.> | | Subject | Re: [open-mmlab/mmcv] from mmcv import Config ImportError: cannot import name 'Config' (#1329) |

same problem on mmcv2.0.0

mmcls 0.25.0 mmcv 2.0.0 mmengine 0.7.2 mmsegmentation 1.0.0

install by mim

MMCV2.0.0没有定义Config, 是在MMengine中定义的

请问怎么解决?多谢!

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

wangliangwu commented 1 year ago

because mmcv 2.0 did not have the Config function just try this method the first pip uninstall mmcv the second pip install mmcv==1.6 the the problem will be solved ,i try it ,and solve my problems

kochenyu commented 1 year ago

just change from mmcv import Config to from mmengine import Config

qsd-github commented 10 months ago

from mmengine import Config,Perfect solution!